| /******************************************************************************* |
| * Copyright (c) 2006, 2007 Oracle. All rights reserved. |
| * This program and the accompanying materials are made available under the |
| * terms of the Eclipse Public License v1.0, which accompanies this distribution |
| * and is available at http://www.eclipse.org/legal/epl-v10.html. |
| * |
| * Contributors: |
| * Oracle - initial API and implementation |
| ******************************************************************************/ |
| package org.eclipse.jpt.core.internal.content.orm; |
| |
| import java.util.Iterator; |
| import org.eclipse.emf.common.notify.Notification; |
| import org.eclipse.emf.ecore.EClass; |
| import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| import org.eclipse.jpt.core.internal.IMappingKeys; |
| import org.eclipse.jpt.core.internal.IPersistentAttribute; |
| import org.eclipse.jpt.core.internal.mappings.IMappedSuperclass; |
| import org.eclipse.jpt.core.internal.mappings.ITable; |
| import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage; |
| import org.eclipse.jpt.utility.internal.iterators.EmptyIterator; |
| import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; |
| import org.eclipse.jpt.utility.internal.iterators.TransformationIterator; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Xml Mapped Superclass</b></em>'. |
| * <!-- end-user-doc --> |
| * |
| * |
| * @see org.eclipse.jpt.core.internal.content.orm.OrmPackage#getXmlMappedSuperclass() |
| * @model kind="class" |
| * @generated |
| */ |
| public class XmlMappedSuperclass extends XmlTypeMapping |
| implements IMappedSuperclass |
| { |
| /** |
| * The default value of the '{@link #getIdClass() <em>Id Class</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getIdClass() |
| * @generated |
| * @ordered |
| */ |
| protected static final String ID_CLASS_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getIdClass() <em>Id Class</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getIdClass() |
| * @generated |
| * @ordered |
| */ |
| protected String idClass = ID_CLASS_EDEFAULT; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected XmlMappedSuperclass() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return OrmPackage.Literals.XML_MAPPED_SUPERCLASS; |
| } |
| |
| /** |
| * Returns the value of the '<em><b>Id Class</b></em>' attribute. |
| * <!-- begin-user-doc --> |
| * <p> |
| * If the meaning of the '<em>Id Class</em>' attribute isn't clear, |
| * there really should be more of a description here... |
| * </p> |
| * <!-- end-user-doc --> |
| * @return the value of the '<em>Id Class</em>' attribute. |
| * @see #setIdClass(String) |
| * @see org.eclipse.jpt.core.internal.content.orm.OrmPackage#getIMappedSuperclass_IdClass() |
| * @model |
| * @generated |
| */ |
| public String getIdClass() { |
| return idClass; |
| } |
| |
| /** |
| * Sets the value of the '{@link org.eclipse.jpt.core.internal.content.orm.XmlMappedSuperclass#getIdClass <em>Id Class</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @param value the new value of the '<em>Id Class</em>' attribute. |
| * @see #getIdClass() |
| * @generated |
| */ |
| public void setIdClass(String newIdClass) { |
| String oldIdClass = idClass; |
| idClass = newIdClass; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.XML_MAPPED_SUPERCLASS__ID_CLASS, oldIdClass, idClass)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) { |
| case OrmPackage.XML_MAPPED_SUPERCLASS__ID_CLASS : |
| return getIdClass(); |
| } |
| return super.eGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eSet(int featureID, Object newValue) { |
| switch (featureID) { |
| case OrmPackage.XML_MAPPED_SUPERCLASS__ID_CLASS : |
| setIdClass((String) newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case OrmPackage.XML_MAPPED_SUPERCLASS__ID_CLASS : |
| setIdClass(ID_CLASS_EDEFAULT); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case OrmPackage.XML_MAPPED_SUPERCLASS__ID_CLASS : |
| return ID_CLASS_EDEFAULT == null ? idClass != null : !ID_CLASS_EDEFAULT.equals(idClass); |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) { |
| if (baseClass == IMappedSuperclass.class) { |
| switch (derivedFeatureID) { |
| case OrmPackage.XML_MAPPED_SUPERCLASS__ID_CLASS : |
| return JpaCoreMappingsPackage.IMAPPED_SUPERCLASS__ID_CLASS; |
| default : |
| return -1; |
| } |
| } |
| return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) { |
| if (baseClass == IMappedSuperclass.class) { |
| switch (baseFeatureID) { |
| case JpaCoreMappingsPackage.IMAPPED_SUPERCLASS__ID_CLASS : |
| return OrmPackage.XML_MAPPED_SUPERCLASS__ID_CLASS; |
| default : |
| return -1; |
| } |
| } |
| return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String toString() { |
| if (eIsProxy()) |
| return super.toString(); |
| StringBuffer result = new StringBuffer(super.toString()); |
| result.append(" (idClass: "); |
| result.append(idClass); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| public String getKey() { |
| return IMappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY; |
| } |
| |
| public boolean tableNameIsInvalid(String tableName) { |
| return false; |
| } |
| |
| public Iterator<String> associatedTableNamesIncludingInherited() { |
| return EmptyIterator.instance(); |
| } |
| |
| public Iterator<ITable> associatedTables() { |
| return EmptyIterator.instance(); |
| } |
| |
| public Iterator<ITable> associatedTablesIncludingInherited() { |
| return EmptyIterator.instance(); |
| } |
| |
| public Iterator<String> overridableAttributeNames() { |
| return this.namesOf(this.overridableAttributes()); |
| } |
| |
| public Iterator<IPersistentAttribute> overridableAttributes() { |
| return new FilteringIterator<IPersistentAttribute>(this.getPersistentType().attributes()) { |
| @Override |
| protected boolean accept(Object o) { |
| return ((IPersistentAttribute) o).isOverridableAttribute(); |
| } |
| }; |
| } |
| |
| public Iterator<String> overridableAssociationNames() { |
| return this.namesOf(this.overridableAssociations()); |
| } |
| |
| public Iterator<IPersistentAttribute> overridableAssociations() { |
| return new FilteringIterator<IPersistentAttribute>(this.getPersistentType().attributes()) { |
| @Override |
| protected boolean accept(Object o) { |
| return ((IPersistentAttribute) o).isOverridableAssociation(); |
| } |
| }; |
| } |
| |
| private Iterator<String> namesOf(Iterator<IPersistentAttribute> attributes) { |
| return new TransformationIterator<IPersistentAttribute, String>(attributes) { |
| @Override |
| protected String transform(IPersistentAttribute attribute) { |
| return attribute.getName(); |
| } |
| }; |
| } |
| |
| @Override |
| public int xmlSequence() { |
| return 0; |
| } |
| } |