diff options
22 files changed, 2002 insertions, 5 deletions
diff --git a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EClassImpl.java b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EClassImpl.java index 55dae8757..3911fc48b 100644 --- a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EClassImpl.java +++ b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EClassImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2002-2009 IBM Corporation and others. + * Copyright (c) 2002-2014 IBM Corporation, CEA, and others. * 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 @@ -7,6 +7,7 @@ * * Contributors: * IBM - Initial API and implementation + * Christian W. Damus (CEA) - 433108 */ package org.eclipse.emf.ecore.impl; @@ -148,6 +149,10 @@ public class EClassImpl extends EClassifierImpl implements EClass, ESuperAdapter freeze(eOperations.get(i)); } } + + // Bug 433108: Lock in the shared extended metadata for this class + ExtendedMetaData.INSTANCE.getName(this); + super.freeze(); } diff --git a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EDataTypeImpl.java b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EDataTypeImpl.java index 30e13908a..0f2df33d3 100644 --- a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EDataTypeImpl.java +++ b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EDataTypeImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2002-2006 IBM Corporation and others. + * Copyright (c) 2002-2014 IBM Corporation, CEA, and others. * 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 @@ -7,6 +7,7 @@ * * Contributors: * IBM - Initial API and implementation + * Christian W. Damus (CEA) - 433108 */ package org.eclipse.emf.ecore.impl; @@ -21,6 +22,7 @@ import org.eclipse.emf.ecore.EDataType; import org.eclipse.emf.ecore.ETypeParameter; import org.eclipse.emf.ecore.EcorePackage; import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.ExtendedMetaData; /** @@ -70,6 +72,15 @@ public class EDataTypeImpl extends EClassifierImpl implements EDataType, EDataTy eFlags |= SERIALIZABLE_EFLAG; } + @Override + protected void freeze() + { + // Bug 433108: Lock in the shared extended metadata for this data type + ExtendedMetaData.INSTANCE.getName(this); + + super.freeze(); + } + protected Object defaultValue = null; protected boolean defaultValueIsSet = false; diff --git a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EPackageImpl.java b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EPackageImpl.java index 4bf2550a0..d0bddd26c 100644 --- a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EPackageImpl.java +++ b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EPackageImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2002-2009 IBM Corporation and others. + * Copyright (c) 2002-2014 IBM Corporation, CEA, and others. * 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 @@ -7,6 +7,7 @@ * * Contributors: * IBM - Initial API and implementation + * Christian W. Damus (CEA) - 433108 */ package org.eclipse.emf.ecore.impl; @@ -204,6 +205,10 @@ public class EPackageImpl extends ENamedElementImpl implements EPackage, BasicEx freeze(eSubpackages.get(i)); } } + + // Bug 433108: Lock in the shared extended metadata for this package + ExtendedMetaData.INSTANCE.getNamespace(this); + super.freeze(); } diff --git a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EStructuralFeatureImpl.java b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EStructuralFeatureImpl.java index addad9940..ed4af9b0d 100644 --- a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EStructuralFeatureImpl.java +++ b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EStructuralFeatureImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2002-2012 IBM Corporation and others. + * Copyright (c) 2002-2014 IBM Corporation, CEA, and others. * 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 @@ -7,6 +7,7 @@ * * Contributors: * IBM - Initial API and implementation + * Christian W. Damus (CEA) - 433108 */ package org.eclipse.emf.ecore.impl; @@ -100,6 +101,15 @@ public abstract class EStructuralFeatureImpl extends ETypedElementImpl implement return EcorePackage.Literals.ESTRUCTURAL_FEATURE; } + @Override + protected void freeze() + { + // Bug 433108: Lock in the shared extended metadata for this feature + ExtendedMetaData.INSTANCE.getName(this); + + super.freeze(); + } + protected Object defaultValue = null; protected EFactory defaultValueFactory = null; diff --git a/tests/org.eclipse.emf.test.core/META-INF/MANIFEST.MF b/tests/org.eclipse.emf.test.core/META-INF/MANIFEST.MF index 133bb8092..195b8670a 100644 --- a/tests/org.eclipse.emf.test.core/META-INF/MANIFEST.MF +++ b/tests/org.eclipse.emf.test.core/META-INF/MANIFEST.MF @@ -13,6 +13,9 @@ Export-Package: org.eclipse.emf.test.core, org.eclipse.emf.test.core.common.util, org.eclipse.emf.test.core.dynamic, org.eclipse.emf.test.core.ecore, + org.eclipse.emf.test.core.extmetadata, + org.eclipse.emf.test.core.extmetadata.impl, + org.eclipse.emf.test.core.extmetadata.util, org.eclipse.emf.test.core.featuremap, org.eclipse.emf.test.core.featuremap.supplier, org.eclipse.emf.test.core.featuremap.supplier.impl, diff --git a/tests/org.eclipse.emf.test.core/data/extmetadata.xmi b/tests/org.eclipse.emf.test.core/data/extmetadata.xmi new file mode 100644 index 000000000..1cc47525c --- /dev/null +++ b/tests/org.eclipse.emf.test.core/data/extmetadata.xmi @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="ASCII"?> +<xmi:XMI xmi:version="2.0" + xmlns:xmi="http://www.omg.org/XMI" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:xmd="http://www.eclipse.org/emf/2014/test/extmetadata" + xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" + xmlns:thing="http://www.eclipse.org/emf/2014/test/thing" + xsi:schemaLocation="http://www.eclipse.org/emf/2014/test/thing #/0"> + <ecore:EPackage name="thing" nsURI="http://www.eclipse.org/emf/2014/test/thing" nsPrefix="thing"> + <eClassifiers xsi:type="ecore:EClass" name="Thing"/> + </ecore:EPackage> + <xmd:Class + name="Fruit"> + <attribute + name="colour" + type="/1"/> + <attribute + name="symmetry" + type="/2"/> + </xmd:Class> + <xmd:Class + name="Colour"/> + <xmd:Class + name="Symmetry"/> + <thing:Thing/> +</xmi:XMI> diff --git a/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/AllSuites.java b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/AllSuites.java index 07bf56366..93b3cc9d2 100644 --- a/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/AllSuites.java +++ b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/AllSuites.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2002-2013 IBM Corporation and others. + * Copyright (c) 2002-2014 IBM Corporation, CEA, and others. * 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 @@ -7,6 +7,7 @@ * * Contributors: * IBM - Initial API and implementation + * Christian W. Damus (CEA) - 433108 */ package org.eclipse.emf.test.core; @@ -22,6 +23,7 @@ public class AllSuites extends TestSuite private static Test[] suites = new Test [] { + org.eclipse.emf.test.core.ecore.BasicExtendedMetadataTest.suite(), org.eclipse.emf.test.core.ecore.EcoreValidationTest.suite(), org.eclipse.emf.test.core.ecore.EcoreTest.suite(), org.eclipse.emf.test.core.common.NotificationTest.suite(), diff --git a/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/ecore/BasicExtendedMetadataTest.java b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/ecore/BasicExtendedMetadataTest.java new file mode 100644 index 000000000..ec0e38343 --- /dev/null +++ b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/ecore/BasicExtendedMetadataTest.java @@ -0,0 +1,117 @@ +/** + * Copyright (c) 2014 CEA and others. + * 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: + * CEA - Initial API and implementation + */ +package org.eclipse.emf.test.core.ecore; + + +import java.lang.reflect.Field; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.ecore.util.BasicExtendedMetaData; +import org.eclipse.emf.ecore.util.ExtendedMetaData; +import org.eclipse.emf.ecore.xmi.XMLResource; +import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; +import org.eclipse.emf.test.common.TestUtil; +import org.eclipse.emf.test.core.AllSuites; +import org.eclipse.emf.test.core.extmetadata.ExtmetadataPackage; + + +/** + * <b>NOTE</b> that this class has a test case that requires no instance models described by + * the {@link ExtmetadataPackage} to have been loaded prior to its execution. So, if any + * other tests use that package, this test must be the first to run. + */ +public class BasicExtendedMetadataTest extends TestCase +{ + + private static final String THING_NAMESPACE = "http://www.eclipse.org/emf/2014/test/thing"; + + public BasicExtendedMetadataTest(String name) + { + super(name); + } + + public static Test suite() + { + TestSuite ts = new TestSuite("BasicExtendedMetadataTest"); + ts.addTest(new BasicExtendedMetadataTest("testDynamicEPackageLeak")); + return ts; + } + + /** + * Test that dynamic EPackages embedded in a user-model resource, added to a + * resource set's local package registry, are not leaked in the extended + * metadata of statically registered (generated) EPackages. + * + * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=433108 + */ + public void testDynamicEPackageLeak() + { + // Initialize the static EPackage + ExtmetadataPackage.eINSTANCE.eClass(); + + // Load an instance model (which includes a dynamic Thing EPackage) + ResourceSet rset = new ResourceSetImpl(); + rset.getLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, true); + rset.getLoadOptions().put(XMLResource.OPTION_LAX_FEATURE_PROCESSING, true); + + rset.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl()); + Resource res = rset.getResource(URI.createFileURI(TestUtil.getPluginDirectory(AllSuites.PLUGIN_ID) + "/data/extmetadata.xmi"), true); + + // Find the dynamic Thing package + EPackage thingPackage = rset.getPackageRegistry().getEPackage(THING_NAMESPACE); + assertNotNull("Did not find Thing package", thingPackage); + + res.unload(); + assertTrue("Thing package was not unloaded", thingPackage.eIsProxy()); + + // Look for the leaked thing package in the extended metadata of the static package + BasicExtendedMetaData.EStructuralFeatureExtendedMetaData featureMetadata = ((BasicExtendedMetaData.EStructuralFeatureExtendedMetaData.Holder)ExtmetadataPackage.Literals.ATTRIBUTE__TYPE).getExtendedMetaData(); + if (featureMetadata != null) + { + ExtendedMetaData outerMetadata = getOuterClassInstance(featureMetadata, ExtendedMetaData.class); + EPackage foundPackage = outerMetadata.getPackage(THING_NAMESPACE); + + // Either we should not find any Thing package, or it would be demand-created and thus be a different + // instance of the Java EPackage class + assertTrue("Thing package was leaked", (foundPackage == null) || (foundPackage != thingPackage)); + } + } + + // + // Test framework + // + + <T> T getOuterClassInstance(Object o, Class<T> outerClass) + { + try + { + Field dollarsZero = o.getClass().getDeclaredField("this$0"); + dollarsZero.setAccessible(true); + Object result = dollarsZero.get(o); + assertTrue("Wrong outer class type", outerClass.isInstance(result)); + return outerClass.cast(result); + } + catch (Exception e) + { + e.printStackTrace(); + fail("Could not get outer class instance: " + e.getLocalizedMessage()); + return null; // Unreachable + } + } +} diff --git a/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/Attribute.java b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/Attribute.java new file mode 100644 index 000000000..4f9983cc6 --- /dev/null +++ b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/Attribute.java @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2014 CEA and others. + * 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: + * CEA - Initial API and implementation + * + */ +package org.eclipse.emf.test.core.extmetadata; + + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>Attribute</b></em>'. + * <!-- end-user-doc --> + * + * <p> + * The following features are supported: + * <ul> + * <li>{@link org.eclipse.emf.test.core.extmetadata.Attribute#getType <em>Type</em>}</li> + * </ul> + * </p> + * + * @see org.eclipse.emf.test.core.extmetadata.ExtmetadataPackage#getAttribute() + * @model + * @generated + */ +public interface Attribute extends NamedElement { + /** + * Returns the value of the '<em><b>Type</b></em>' reference. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Type</em>' reference isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Type</em>' reference. + * @see #setType(org.eclipse.emf.test.core.extmetadata.Class) + * @see org.eclipse.emf.test.core.extmetadata.ExtmetadataPackage#getAttribute_Type() + * @model required="true" + * @generated + */ + org.eclipse.emf.test.core.extmetadata.Class getType(); + + /** + * Sets the value of the '{@link org.eclipse.emf.test.core.extmetadata.Attribute#getType <em>Type</em>}' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Type</em>' reference. + * @see #getType() + * @generated + */ + void setType(org.eclipse.emf.test.core.extmetadata.Class value); + +} // Attribute diff --git a/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/Class.java b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/Class.java new file mode 100644 index 000000000..680cf78a8 --- /dev/null +++ b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/Class.java @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2014 CEA and others. + * 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: + * CEA - Initial API and implementation + * + */ +package org.eclipse.emf.test.core.extmetadata; + +import org.eclipse.emf.common.util.EList; + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>Class</b></em>'. + * <!-- end-user-doc --> + * + * <p> + * The following features are supported: + * <ul> + * <li>{@link org.eclipse.emf.test.core.extmetadata.Class#getAttribute <em>Attribute</em>}</li> + * </ul> + * </p> + * + * @see org.eclipse.emf.test.core.extmetadata.ExtmetadataPackage#getClass_() + * @model + * @generated + */ +public interface Class extends NamedElement { + /** + * Returns the value of the '<em><b>Attribute</b></em>' containment reference list. + * The list contents are of type {@link org.eclipse.emf.test.core.extmetadata.Attribute}. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Attribute</em>' containment reference list isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Attribute</em>' containment reference list. + * @see org.eclipse.emf.test.core.extmetadata.ExtmetadataPackage#getClass_Attribute() + * @model containment="true" + * @generated + */ + EList<Attribute> getAttribute(); + +} // Class diff --git a/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/ExtmetadataFactory.java b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/ExtmetadataFactory.java new file mode 100644 index 000000000..cda74f5e1 --- /dev/null +++ b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/ExtmetadataFactory.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) 2014 CEA and others. + * 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: + * CEA - Initial API and implementation + * + */ +package org.eclipse.emf.test.core.extmetadata; + +import org.eclipse.emf.ecore.EFactory; + +/** + * <!-- begin-user-doc --> + * The <b>Factory</b> for the model. + * It provides a create method for each non-abstract class of the model. + * <!-- end-user-doc --> + * @see org.eclipse.emf.test.core.extmetadata.ExtmetadataPackage + * @generated + */ +public interface ExtmetadataFactory extends EFactory { + /** + * The singleton instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + ExtmetadataFactory eINSTANCE = org.eclipse.emf.test.core.extmetadata.impl.ExtmetadataFactoryImpl.init(); + + /** + * Returns a new object of class '<em>Named Element</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Named Element</em>'. + * @generated + */ + NamedElement createNamedElement(); + + /** + * Returns a new object of class '<em>Class</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Class</em>'. + * @generated + */ + Class createClass(); + + /** + * Returns a new object of class '<em>Attribute</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Attribute</em>'. + * @generated + */ + Attribute createAttribute(); + + /** + * Returns the package supported by this factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the package supported by this factory. + * @generated + */ + ExtmetadataPackage getExtmetadataPackage(); + +} //ExtmetadataFactory diff --git a/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/ExtmetadataPackage.java b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/ExtmetadataPackage.java new file mode 100644 index 000000000..70354d808 --- /dev/null +++ b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/ExtmetadataPackage.java @@ -0,0 +1,340 @@ +/** + * Copyright (c) 2014 CEA and others. + * 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: + * CEA - Initial API and implementation + * + */ +package org.eclipse.emf.test.core.extmetadata; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +/** + * <!-- begin-user-doc --> + * The <b>Package</b> for the model. + * It contains accessors for the meta objects to represent + * <ul> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each operation of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * @see org.eclipse.emf.test.core.extmetadata.ExtmetadataFactory + * @model kind="package" + * @generated + */ +public interface ExtmetadataPackage extends EPackage { + /** + * The package name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + String eNAME = "extmetadata"; + + /** + * The package namespace URI. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + String eNS_URI = "http://www.eclipse.org/emf/2014/test/extmetadata"; + + /** + * The package namespace name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + String eNS_PREFIX = "xmd"; + + /** + * The singleton instance of the package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + ExtmetadataPackage eINSTANCE = org.eclipse.emf.test.core.extmetadata.impl.ExtmetadataPackageImpl.init(); + + /** + * The meta object id for the '{@link org.eclipse.emf.test.core.extmetadata.impl.NamedElementImpl <em>Named Element</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.test.core.extmetadata.impl.NamedElementImpl + * @see org.eclipse.emf.test.core.extmetadata.impl.ExtmetadataPackageImpl#getNamedElement() + * @generated + */ + int NAMED_ELEMENT = 0; + + /** + * The feature id for the '<em><b>Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int NAMED_ELEMENT__NAME = 0; + + /** + * The number of structural features of the '<em>Named Element</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int NAMED_ELEMENT_FEATURE_COUNT = 1; + + /** + * The number of operations of the '<em>Named Element</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int NAMED_ELEMENT_OPERATION_COUNT = 0; + + /** + * The meta object id for the '{@link org.eclipse.emf.test.core.extmetadata.impl.ClassImpl <em>Class</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.test.core.extmetadata.impl.ClassImpl + * @see org.eclipse.emf.test.core.extmetadata.impl.ExtmetadataPackageImpl#getClass_() + * @generated + */ + int CLASS = 1; + + /** + * The feature id for the '<em><b>Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CLASS__NAME = NAMED_ELEMENT__NAME; + + /** + * The feature id for the '<em><b>Attribute</b></em>' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CLASS__ATTRIBUTE = NAMED_ELEMENT_FEATURE_COUNT + 0; + + /** + * The number of structural features of the '<em>Class</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CLASS_FEATURE_COUNT = NAMED_ELEMENT_FEATURE_COUNT + 1; + + /** + * The number of operations of the '<em>Class</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CLASS_OPERATION_COUNT = NAMED_ELEMENT_OPERATION_COUNT + 0; + + /** + * The meta object id for the '{@link org.eclipse.emf.test.core.extmetadata.impl.AttributeImpl <em>Attribute</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.test.core.extmetadata.impl.AttributeImpl + * @see org.eclipse.emf.test.core.extmetadata.impl.ExtmetadataPackageImpl#getAttribute() + * @generated + */ + int ATTRIBUTE = 2; + + /** + * The feature id for the '<em><b>Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ATTRIBUTE__NAME = NAMED_ELEMENT__NAME; + + /** + * The feature id for the '<em><b>Type</b></em>' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ATTRIBUTE__TYPE = NAMED_ELEMENT_FEATURE_COUNT + 0; + + /** + * The number of structural features of the '<em>Attribute</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ATTRIBUTE_FEATURE_COUNT = NAMED_ELEMENT_FEATURE_COUNT + 1; + + /** + * The number of operations of the '<em>Attribute</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ATTRIBUTE_OPERATION_COUNT = NAMED_ELEMENT_OPERATION_COUNT + 0; + + + /** + * Returns the meta object for class '{@link org.eclipse.emf.test.core.extmetadata.NamedElement <em>Named Element</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Named Element</em>'. + * @see org.eclipse.emf.test.core.extmetadata.NamedElement + * @generated + */ + EClass getNamedElement(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.test.core.extmetadata.NamedElement#getName <em>Name</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Name</em>'. + * @see org.eclipse.emf.test.core.extmetadata.NamedElement#getName() + * @see #getNamedElement() + * @generated + */ + EAttribute getNamedElement_Name(); + + /** + * Returns the meta object for class '{@link org.eclipse.emf.test.core.extmetadata.Class <em>Class</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Class</em>'. + * @see org.eclipse.emf.test.core.extmetadata.Class + * @generated + */ + EClass getClass_(); + + /** + * Returns the meta object for the containment reference list '{@link org.eclipse.emf.test.core.extmetadata.Class#getAttribute <em>Attribute</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the containment reference list '<em>Attribute</em>'. + * @see org.eclipse.emf.test.core.extmetadata.Class#getAttribute() + * @see #getClass_() + * @generated + */ + EReference getClass_Attribute(); + + /** + * Returns the meta object for class '{@link org.eclipse.emf.test.core.extmetadata.Attribute <em>Attribute</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Attribute</em>'. + * @see org.eclipse.emf.test.core.extmetadata.Attribute + * @generated + */ + EClass getAttribute(); + + /** + * Returns the meta object for the reference '{@link org.eclipse.emf.test.core.extmetadata.Attribute#getType <em>Type</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the reference '<em>Type</em>'. + * @see org.eclipse.emf.test.core.extmetadata.Attribute#getType() + * @see #getAttribute() + * @generated + */ + EReference getAttribute_Type(); + + /** + * Returns the factory that creates the instances of the model. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the factory that creates the instances of the model. + * @generated + */ + ExtmetadataFactory getExtmetadataFactory(); + + /** + * <!-- begin-user-doc --> + * Defines literals for the meta objects that represent + * <ul> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each operation of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * @generated + */ + interface Literals { + /** + * The meta object literal for the '{@link org.eclipse.emf.test.core.extmetadata.impl.NamedElementImpl <em>Named Element</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.test.core.extmetadata.impl.NamedElementImpl + * @see org.eclipse.emf.test.core.extmetadata.impl.ExtmetadataPackageImpl#getNamedElement() + * @generated + */ + EClass NAMED_ELEMENT = eINSTANCE.getNamedElement(); + + /** + * The meta object literal for the '<em><b>Name</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EAttribute NAMED_ELEMENT__NAME = eINSTANCE.getNamedElement_Name(); + + /** + * The meta object literal for the '{@link org.eclipse.emf.test.core.extmetadata.impl.ClassImpl <em>Class</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.test.core.extmetadata.impl.ClassImpl + * @see org.eclipse.emf.test.core.extmetadata.impl.ExtmetadataPackageImpl#getClass_() + * @generated + */ + EClass CLASS = eINSTANCE.getClass_(); + + /** + * The meta object literal for the '<em><b>Attribute</b></em>' containment reference list feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EReference CLASS__ATTRIBUTE = eINSTANCE.getClass_Attribute(); + + /** + * The meta object literal for the '{@link org.eclipse.emf.test.core.extmetadata.impl.AttributeImpl <em>Attribute</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.test.core.extmetadata.impl.AttributeImpl + * @see org.eclipse.emf.test.core.extmetadata.impl.ExtmetadataPackageImpl#getAttribute() + * @generated + */ + EClass ATTRIBUTE = eINSTANCE.getAttribute(); + + /** + * The meta object literal for the '<em><b>Type</b></em>' reference feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EReference ATTRIBUTE__TYPE = eINSTANCE.getAttribute_Type(); + + } + +} //ExtmetadataPackage diff --git a/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/NamedElement.java b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/NamedElement.java new file mode 100644 index 000000000..9fa698f09 --- /dev/null +++ b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/NamedElement.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2014 CEA and others. + * 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: + * CEA - Initial API and implementation + * + */ +package org.eclipse.emf.test.core.extmetadata; + +import org.eclipse.emf.ecore.EObject; + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>Named Element</b></em>'. + * <!-- end-user-doc --> + * + * <p> + * The following features are supported: + * <ul> + * <li>{@link org.eclipse.emf.test.core.extmetadata.NamedElement#getName <em>Name</em>}</li> + * </ul> + * </p> + * + * @see org.eclipse.emf.test.core.extmetadata.ExtmetadataPackage#getNamedElement() + * @model + * @generated + */ +public interface NamedElement extends EObject { + /** + * Returns the value of the '<em><b>Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Name</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Name</em>' attribute. + * @see #setName(String) + * @see org.eclipse.emf.test.core.extmetadata.ExtmetadataPackage#getNamedElement_Name() + * @model required="true" + * @generated + */ + String getName(); + + /** + * Sets the value of the '{@link org.eclipse.emf.test.core.extmetadata.NamedElement#getName <em>Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Name</em>' attribute. + * @see #getName() + * @generated + */ + void setName(String value); + +} // NamedElement diff --git a/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/extmetadata.ecore b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/extmetadata.ecore new file mode 100644 index 000000000..d4865141d --- /dev/null +++ b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/extmetadata.ecore @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="extmetadata" nsURI="http://www.eclipse.org/emf/2014/test/extmetadata" + nsPrefix="xmd"> + <eClassifiers xsi:type="ecore:EClass" name="NamedElement"> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Class" eSuperTypes="#//NamedElement"> + <eStructuralFeatures xsi:type="ecore:EReference" name="attribute" upperBound="-1" + eType="#//Attribute" containment="true"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Attribute" eSuperTypes="#//NamedElement"> + <eStructuralFeatures xsi:type="ecore:EReference" name="type" lowerBound="1" eType="#//Class"/> + </eClassifiers> +</ecore:EPackage> diff --git a/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/extmetadata.genmodel b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/extmetadata.genmodel new file mode 100644 index 000000000..d09c0f45a --- /dev/null +++ b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/extmetadata.genmodel @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" + xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" copyrightText="Copyright (c) 2014 CEA and others.
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:
 CEA - Initial API and implementation
" + modelDirectory="/org.eclipse.emf.test.core/src" modelPluginID="org.eclipse.emf.test.core" + modelName="Extmetadata" rootExtendsClass="org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container" + importerID="org.eclipse.emf.importer.ecore" complianceLevel="5.0" copyrightFields="false" + operationReflection="true" importOrganizing="true"> + <foreignModel>extmetadata.ecore</foreignModel> + <genPackages prefix="Extmetadata" basePackage="org.eclipse.emf.test.core" disposableProviderFactory="true" + ecorePackage="extmetadata.ecore#/"> + <genClasses ecoreClass="extmetadata.ecore#//NamedElement"> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute extmetadata.ecore#//NamedElement/name"/> + </genClasses> + <genClasses ecoreClass="extmetadata.ecore#//Class"> + <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference extmetadata.ecore#//Class/attribute"/> + </genClasses> + <genClasses ecoreClass="extmetadata.ecore#//Attribute"> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference extmetadata.ecore#//Attribute/type"/> + </genClasses> + </genPackages> +</genmodel:GenModel> diff --git a/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/impl/AttributeImpl.java b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/impl/AttributeImpl.java new file mode 100644 index 000000000..ff075ca84 --- /dev/null +++ b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/impl/AttributeImpl.java @@ -0,0 +1,164 @@ +/** + * Copyright (c) 2014 CEA and others. + * 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: + * CEA - Initial API and implementation + * + */ +package org.eclipse.emf.test.core.extmetadata.impl; + +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; + +import org.eclipse.emf.test.core.extmetadata.Attribute; +import org.eclipse.emf.test.core.extmetadata.ExtmetadataPackage; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Attribute</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.eclipse.emf.test.core.extmetadata.impl.AttributeImpl#getType <em>Type</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class AttributeImpl extends NamedElementImpl implements Attribute { + /** + * The cached value of the '{@link #getType() <em>Type</em>}' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getType() + * @generated + * @ordered + */ + protected org.eclipse.emf.test.core.extmetadata.Class type; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected AttributeImpl() { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + protected EClass eStaticClass() { + return ExtmetadataPackage.Literals.ATTRIBUTE; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public org.eclipse.emf.test.core.extmetadata.Class getType() { + if (type != null && type.eIsProxy()) { + InternalEObject oldType = (InternalEObject)type; + type = (org.eclipse.emf.test.core.extmetadata.Class)eResolveProxy(oldType); + if (type != oldType) { + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.RESOLVE, ExtmetadataPackage.ATTRIBUTE__TYPE, oldType, type)); + } + } + return type; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public org.eclipse.emf.test.core.extmetadata.Class basicGetType() { + return type; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setType(org.eclipse.emf.test.core.extmetadata.Class newType) { + org.eclipse.emf.test.core.extmetadata.Class oldType = type; + type = newType; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ExtmetadataPackage.ATTRIBUTE__TYPE, oldType, type)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case ExtmetadataPackage.ATTRIBUTE__TYPE: + if (resolve) return getType(); + return basicGetType(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case ExtmetadataPackage.ATTRIBUTE__TYPE: + setType((org.eclipse.emf.test.core.extmetadata.Class)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case ExtmetadataPackage.ATTRIBUTE__TYPE: + setType((org.eclipse.emf.test.core.extmetadata.Class)null); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case ExtmetadataPackage.ATTRIBUTE__TYPE: + return type != null; + } + return super.eIsSet(featureID); + } + +} //AttributeImpl diff --git a/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/impl/ClassImpl.java b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/impl/ClassImpl.java new file mode 100644 index 000000000..d8fb65fce --- /dev/null +++ b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/impl/ClassImpl.java @@ -0,0 +1,158 @@ +/** + * Copyright (c) 2014 CEA and others. + * 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: + * CEA - Initial API and implementation + * + */ +package org.eclipse.emf.test.core.extmetadata.impl; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.InternalEList; + +import org.eclipse.emf.test.core.extmetadata.Attribute; +import org.eclipse.emf.test.core.extmetadata.ExtmetadataPackage; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Class</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.eclipse.emf.test.core.extmetadata.impl.ClassImpl#getAttribute <em>Attribute</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class ClassImpl extends NamedElementImpl implements org.eclipse.emf.test.core.extmetadata.Class { + /** + * The cached value of the '{@link #getAttribute() <em>Attribute</em>}' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getAttribute() + * @generated + * @ordered + */ + protected EList<Attribute> attribute; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected ClassImpl() { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + protected EClass eStaticClass() { + return ExtmetadataPackage.Literals.CLASS; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EList<Attribute> getAttribute() { + if (attribute == null) { + attribute = new EObjectContainmentEList<Attribute>(Attribute.class, this, ExtmetadataPackage.CLASS__ATTRIBUTE); + } + return attribute; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case ExtmetadataPackage.CLASS__ATTRIBUTE: + return ((InternalEList<?>)getAttribute()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case ExtmetadataPackage.CLASS__ATTRIBUTE: + return getAttribute(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case ExtmetadataPackage.CLASS__ATTRIBUTE: + getAttribute().clear(); + getAttribute().addAll((Collection<? extends Attribute>)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case ExtmetadataPackage.CLASS__ATTRIBUTE: + getAttribute().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case ExtmetadataPackage.CLASS__ATTRIBUTE: + return attribute != null && !attribute.isEmpty(); + } + return super.eIsSet(featureID); + } + +} //ClassImpl diff --git a/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/impl/ExtmetadataFactoryImpl.java b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/impl/ExtmetadataFactoryImpl.java new file mode 100644 index 000000000..8e24402fb --- /dev/null +++ b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/impl/ExtmetadataFactoryImpl.java @@ -0,0 +1,129 @@ +/** + * Copyright (c) 2014 CEA and others. + * 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: + * CEA - Initial API and implementation + * + */ +package org.eclipse.emf.test.core.extmetadata.impl; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.impl.EFactoryImpl; + +import org.eclipse.emf.ecore.plugin.EcorePlugin; + +import org.eclipse.emf.test.core.extmetadata.Attribute; +import org.eclipse.emf.test.core.extmetadata.ExtmetadataFactory; +import org.eclipse.emf.test.core.extmetadata.ExtmetadataPackage; +import org.eclipse.emf.test.core.extmetadata.NamedElement; + +/** + * <!-- begin-user-doc --> + * An implementation of the model <b>Factory</b>. + * <!-- end-user-doc --> + * @generated + */ +public class ExtmetadataFactoryImpl extends EFactoryImpl implements ExtmetadataFactory { + /** + * Creates the default factory implementation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static ExtmetadataFactory init() { + try { + ExtmetadataFactory theExtmetadataFactory = (ExtmetadataFactory)EPackage.Registry.INSTANCE.getEFactory(ExtmetadataPackage.eNS_URI); + if (theExtmetadataFactory != null) { + return theExtmetadataFactory; + } + } + catch (Exception exception) { + EcorePlugin.INSTANCE.log(exception); + } + return new ExtmetadataFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ExtmetadataFactoryImpl() { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public EObject create(EClass eClass) { + switch (eClass.getClassifierID()) { + case ExtmetadataPackage.NAMED_ELEMENT: return createNamedElement(); + case ExtmetadataPackage.CLASS: return createClass(); + case ExtmetadataPackage.ATTRIBUTE: return createAttribute(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NamedElement createNamedElement() { + NamedElementImpl namedElement = new NamedElementImpl(); + return namedElement; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public org.eclipse.emf.test.core.extmetadata.Class createClass() { + ClassImpl class_ = new ClassImpl(); + return class_; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Attribute createAttribute() { + AttributeImpl attribute = new AttributeImpl(); + return attribute; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ExtmetadataPackage getExtmetadataPackage() { + return (ExtmetadataPackage)getEPackage(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @deprecated + * @generated + */ + @Deprecated + public static ExtmetadataPackage getPackage() { + return ExtmetadataPackage.eINSTANCE; + } + +} //ExtmetadataFactoryImpl diff --git a/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/impl/ExtmetadataPackageImpl.java b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/impl/ExtmetadataPackageImpl.java new file mode 100644 index 000000000..d55dac7c5 --- /dev/null +++ b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/impl/ExtmetadataPackageImpl.java @@ -0,0 +1,252 @@ +/** + * Copyright (c) 2014 CEA and others. + * 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: + * CEA - Initial API and implementation + * + */ +package org.eclipse.emf.test.core.extmetadata.impl; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +import org.eclipse.emf.ecore.impl.EPackageImpl; + +import org.eclipse.emf.test.core.extmetadata.Attribute; +import org.eclipse.emf.test.core.extmetadata.ExtmetadataFactory; +import org.eclipse.emf.test.core.extmetadata.ExtmetadataPackage; +import org.eclipse.emf.test.core.extmetadata.NamedElement; + +/** + * <!-- begin-user-doc --> + * An implementation of the model <b>Package</b>. + * <!-- end-user-doc --> + * @generated + */ +public class ExtmetadataPackageImpl extends EPackageImpl implements ExtmetadataPackage { + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass namedElementEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass classEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass attributeEClass = null; + + /** + * Creates an instance of the model <b>Package</b>, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + * <p>Note: the correct way to create the package is via the static + * factory method {@link #init init()}, which also performs + * initialization of the package, or returns the registered package, + * if one already exists. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see org.eclipse.emf.test.core.extmetadata.ExtmetadataPackage#eNS_URI + * @see #init() + * @generated + */ + private ExtmetadataPackageImpl() { + super(eNS_URI, ExtmetadataFactory.eINSTANCE); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends. + * + * <p>This method is used to initialize {@link ExtmetadataPackage#eINSTANCE} when that field is accessed. + * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static ExtmetadataPackage init() { + if (isInited) return (ExtmetadataPackage)EPackage.Registry.INSTANCE.getEPackage(ExtmetadataPackage.eNS_URI); + + // Obtain or create and register package + ExtmetadataPackageImpl theExtmetadataPackage = (ExtmetadataPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof ExtmetadataPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new ExtmetadataPackageImpl()); + + isInited = true; + + // Create package meta-data objects + theExtmetadataPackage.createPackageContents(); + + // Initialize created meta-data + theExtmetadataPackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theExtmetadataPackage.freeze(); + + + // Update the registry and return the package + EPackage.Registry.INSTANCE.put(ExtmetadataPackage.eNS_URI, theExtmetadataPackage); + return theExtmetadataPackage; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getNamedElement() { + return namedElementEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EAttribute getNamedElement_Name() { + return (EAttribute)namedElementEClass.getEStructuralFeatures().get(0); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getClass_() { + return classEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EReference getClass_Attribute() { + return (EReference)classEClass.getEStructuralFeatures().get(0); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getAttribute() { + return attributeEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EReference getAttribute_Type() { + return (EReference)attributeEClass.getEStructuralFeatures().get(0); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ExtmetadataFactory getExtmetadataFactory() { + return (ExtmetadataFactory)getEFactoryInstance(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void createPackageContents() { + if (isCreated) return; + isCreated = true; + + // Create classes and their features + namedElementEClass = createEClass(NAMED_ELEMENT); + createEAttribute(namedElementEClass, NAMED_ELEMENT__NAME); + + classEClass = createEClass(CLASS); + createEReference(classEClass, CLASS__ATTRIBUTE); + + attributeEClass = createEClass(ATTRIBUTE); + createEReference(attributeEClass, ATTRIBUTE__TYPE); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void initializePackageContents() { + if (isInitialized) return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Create type parameters + + // Set bounds for type parameters + + // Add supertypes to classes + classEClass.getESuperTypes().add(this.getNamedElement()); + attributeEClass.getESuperTypes().add(this.getNamedElement()); + + // Initialize classes, features, and operations; add parameters + initEClass(namedElementEClass, NamedElement.class, "NamedElement", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getNamedElement_Name(), ecorePackage.getEString(), "name", null, 1, 1, NamedElement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(classEClass, org.eclipse.emf.test.core.extmetadata.Class.class, "Class", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getClass_Attribute(), this.getAttribute(), null, "attribute", null, 0, -1, org.eclipse.emf.test.core.extmetadata.Class.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(attributeEClass, Attribute.class, "Attribute", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getAttribute_Type(), this.getClass_(), null, "type", null, 1, 1, Attribute.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + // Create resource + createResource(eNS_URI); + } + +} //ExtmetadataPackageImpl diff --git a/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/impl/NamedElementImpl.java b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/impl/NamedElementImpl.java new file mode 100644 index 000000000..6f08a2150 --- /dev/null +++ b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/impl/NamedElementImpl.java @@ -0,0 +1,172 @@ +/** + * Copyright (c) 2014 CEA and others. + * 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: + * CEA - Initial API and implementation + * + */ +package org.eclipse.emf.test.core.extmetadata.impl; + +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.test.core.extmetadata.ExtmetadataPackage; +import org.eclipse.emf.test.core.extmetadata.NamedElement; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Named Element</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.eclipse.emf.test.core.extmetadata.impl.NamedElementImpl#getName <em>Name</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class NamedElementImpl extends MinimalEObjectImpl.Container implements NamedElement { + /** + * The default value of the '{@link #getName() <em>Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getName() + * @generated + * @ordered + */ + protected static final String NAME_EDEFAULT = null; + + /** + * The cached value of the '{@link #getName() <em>Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getName() + * @generated + * @ordered + */ + protected String name = NAME_EDEFAULT; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected NamedElementImpl() { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + protected EClass eStaticClass() { + return ExtmetadataPackage.Literals.NAMED_ELEMENT; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getName() { + return name; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setName(String newName) { + String oldName = name; + name = newName; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ExtmetadataPackage.NAMED_ELEMENT__NAME, oldName, name)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case ExtmetadataPackage.NAMED_ELEMENT__NAME: + return getName(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case ExtmetadataPackage.NAMED_ELEMENT__NAME: + setName((String)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case ExtmetadataPackage.NAMED_ELEMENT__NAME: + setName(NAME_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case ExtmetadataPackage.NAMED_ELEMENT__NAME: + return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); + } + return super.eIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (name: "); + result.append(name); + result.append(')'); + return result.toString(); + } + +} //NamedElementImpl diff --git a/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/util/ExtmetadataAdapterFactory.java b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/util/ExtmetadataAdapterFactory.java new file mode 100644 index 000000000..20001605f --- /dev/null +++ b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/util/ExtmetadataAdapterFactory.java @@ -0,0 +1,167 @@ +/** + * Copyright (c) 2014 CEA and others. + * 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: + * CEA - Initial API and implementation + * + */ +package org.eclipse.emf.test.core.extmetadata.util; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notifier; + +import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; + +import org.eclipse.emf.ecore.EObject; + +import org.eclipse.emf.test.core.extmetadata.Attribute; +import org.eclipse.emf.test.core.extmetadata.ExtmetadataPackage; +import org.eclipse.emf.test.core.extmetadata.NamedElement; + +/** + * <!-- begin-user-doc --> + * The <b>Adapter Factory</b> for the model. + * It provides an adapter <code>createXXX</code> method for each class of the model. + * <!-- end-user-doc --> + * @see org.eclipse.emf.test.core.extmetadata.ExtmetadataPackage + * @generated + */ +public class ExtmetadataAdapterFactory extends AdapterFactoryImpl { + /** + * The cached model package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected static ExtmetadataPackage modelPackage; + + /** + * Creates an instance of the adapter factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ExtmetadataAdapterFactory() { + if (modelPackage == null) { + modelPackage = ExtmetadataPackage.eINSTANCE; + } + } + + /** + * Returns whether this factory is applicable for the type of the object. + * <!-- begin-user-doc --> + * This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model. + * <!-- end-user-doc --> + * @return whether this factory is applicable for the type of the object. + * @generated + */ + @Override + public boolean isFactoryForType(Object object) { + if (object == modelPackage) { + return true; + } + if (object instanceof EObject) { + return ((EObject)object).eClass().getEPackage() == modelPackage; + } + return false; + } + + /** + * The switch that delegates to the <code>createXXX</code> methods. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected ExtmetadataSwitch<Adapter> modelSwitch = + new ExtmetadataSwitch<Adapter>() { + @Override + public Adapter caseNamedElement(NamedElement object) { + return createNamedElementAdapter(); + } + @Override + public Adapter caseClass(org.eclipse.emf.test.core.extmetadata.Class object) { + return createClassAdapter(); + } + @Override + public Adapter caseAttribute(Attribute object) { + return createAttributeAdapter(); + } + @Override + public Adapter defaultCase(EObject object) { + return createEObjectAdapter(); + } + }; + + /** + * Creates an adapter for the <code>target</code>. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param target the object to adapt. + * @return the adapter for the <code>target</code>. + * @generated + */ + @Override + public Adapter createAdapter(Notifier target) { + return modelSwitch.doSwitch((EObject)target); + } + + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.emf.test.core.extmetadata.NamedElement <em>Named Element</em>}'. + * <!-- begin-user-doc --> + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * <!-- end-user-doc --> + * @return the new adapter. + * @see org.eclipse.emf.test.core.extmetadata.NamedElement + * @generated + */ + public Adapter createNamedElementAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.emf.test.core.extmetadata.Class <em>Class</em>}'. + * <!-- begin-user-doc --> + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * <!-- end-user-doc --> + * @return the new adapter. + * @see org.eclipse.emf.test.core.extmetadata.Class + * @generated + */ + public Adapter createClassAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.emf.test.core.extmetadata.Attribute <em>Attribute</em>}'. + * <!-- begin-user-doc --> + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * <!-- end-user-doc --> + * @return the new adapter. + * @see org.eclipse.emf.test.core.extmetadata.Attribute + * @generated + */ + public Adapter createAttributeAdapter() { + return null; + } + + /** + * Creates a new adapter for the default case. + * <!-- begin-user-doc --> + * This default implementation returns null. + * <!-- end-user-doc --> + * @return the new adapter. + * @generated + */ + public Adapter createEObjectAdapter() { + return null; + } + +} //ExtmetadataAdapterFactory diff --git a/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/util/ExtmetadataSwitch.java b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/util/ExtmetadataSwitch.java new file mode 100644 index 000000000..eaa5265a2 --- /dev/null +++ b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/extmetadata/util/ExtmetadataSwitch.java @@ -0,0 +1,165 @@ +/** + * Copyright (c) 2014 CEA and others. + * 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: + * CEA - Initial API and implementation + * + */ +package org.eclipse.emf.test.core.extmetadata.util; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.util.Switch; + +import org.eclipse.emf.test.core.extmetadata.Attribute; +import org.eclipse.emf.test.core.extmetadata.ExtmetadataPackage; +import org.eclipse.emf.test.core.extmetadata.NamedElement; + +/** + * <!-- begin-user-doc --> + * The <b>Switch</b> for the model's inheritance hierarchy. + * It supports the call {@link #doSwitch(EObject) doSwitch(object)} + * to invoke the <code>caseXXX</code> method for each class of the model, + * starting with the actual class of the object + * and proceeding up the inheritance hierarchy + * until a non-null result is returned, + * which is the result of the switch. + * <!-- end-user-doc --> + * @see org.eclipse.emf.test.core.extmetadata.ExtmetadataPackage + * @generated + */ +public class ExtmetadataSwitch<T> extends Switch<T> { + /** + * The cached model package + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected static ExtmetadataPackage modelPackage; + + /** + * Creates an instance of the switch. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ExtmetadataSwitch() { + if (modelPackage == null) { + modelPackage = ExtmetadataPackage.eINSTANCE; + } + } + + /** + * Checks whether this is a switch for the given package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @parameter ePackage the package in question. + * @return whether this is a switch for the given package. + * @generated + */ + @Override + protected boolean isSwitchFor(EPackage ePackage) { + return ePackage == modelPackage; + } + + /** + * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the first non-null result returned by a <code>caseXXX</code> call. + * @generated + */ + @Override + protected T doSwitch(int classifierID, EObject theEObject) { + switch (classifierID) { + case ExtmetadataPackage.NAMED_ELEMENT: { + NamedElement namedElement = (NamedElement)theEObject; + T result = caseNamedElement(namedElement); + if (result == null) result = defaultCase(theEObject); + return result; + } + case ExtmetadataPackage.CLASS: { + org.eclipse.emf.test.core.extmetadata.Class class_ = (org.eclipse.emf.test.core.extmetadata.Class)theEObject; + T result = caseClass(class_); + if (result == null) result = caseNamedElement(class_); + if (result == null) result = defaultCase(theEObject); + return result; + } + case ExtmetadataPackage.ATTRIBUTE: { + Attribute attribute = (Attribute)theEObject; + T result = caseAttribute(attribute); + if (result == null) result = caseNamedElement(attribute); + if (result == null) result = defaultCase(theEObject); + return result; + } + default: return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpreting the object as an instance of '<em>Named Element</em>'. + * <!-- begin-user-doc --> + * This implementation returns null; + * returning a non-null result will terminate the switch. + * <!-- end-user-doc --> + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of '<em>Named Element</em>'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseNamedElement(NamedElement object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of '<em>Class</em>'. + * <!-- begin-user-doc --> + * This implementation returns null; + * returning a non-null result will terminate the switch. + * <!-- end-user-doc --> + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of '<em>Class</em>'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseClass(org.eclipse.emf.test.core.extmetadata.Class object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of '<em>Attribute</em>'. + * <!-- begin-user-doc --> + * This implementation returns null; + * returning a non-null result will terminate the switch. + * <!-- end-user-doc --> + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of '<em>Attribute</em>'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseAttribute(Attribute object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. + * <!-- begin-user-doc --> + * This implementation returns null; + * returning a non-null result will terminate the switch, but this is the last case anyway. + * <!-- end-user-doc --> + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of '<em>EObject</em>'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) + * @generated + */ + @Override + public T defaultCase(EObject object) { + return null; + } + +} //ExtmetadataSwitch |