diff options
author | Eike Stepper | 2008-07-02 14:10:04 +0000 |
---|---|---|
committer | Eike Stepper | 2008-07-02 14:10:04 +0000 |
commit | e4505afd9188a19a278baf3a2f33387cbb451edc (patch) | |
tree | d5ebb66a67f1955f5b293225fa6b20fb9b00aab2 | |
parent | 5ecdebb08f25533e1317d49c6fb77fc1cdfe77bf (diff) | |
download | cdo-e4505afd9188a19a278baf3a2f33387cbb451edc.tar.gz cdo-e4505afd9188a19a278baf3a2f33387cbb451edc.tar.xz cdo-e4505afd9188a19a278baf3a2f33387cbb451edc.zip |
[230387] [Hibernate] Issues with package reference
https://bugs.eclipse.org/bugs/show_bug.cgi?id=230387
47 files changed, 3846 insertions, 46 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.tests.hibernate/META-INF/MANIFEST.MF index b63bdf0155..ee9b46e91e 100644 --- a/plugins/org.eclipse.emf.cdo.tests.hibernate/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/META-INF/MANIFEST.MF @@ -18,5 +18,10 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)", org.eclipse.emf.cdo.server.hibernate.teneo;bundle-version="[2.0.0,3.0.0)" Export-Package: mappings;version="2.0.0", org.eclipse.emf.cdo.tests.hibernate;version="2.0.0" -Import-Package: org.hsqldb;version="[1.8.0,2.0.0)", +Import-Package: org.eclipse.emf.teneo, + org.eclipse.emf.teneo.annotations.pamodel, + org.eclipse.emf.teneo.annotations.pamodel.impl, + org.eclipse.emf.teneo.annotations.pamodel.util, + org.eclipse.emf.teneo.annotations.pamodel.validation, + org.hsqldb;version="[1.8.0,2.0.0)", org.hsqldb.jdbc;version="[1.8.0,2.0.0)" diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/CDOPackageRefTest.java b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/CDOPackageRefTest.java new file mode 100644 index 0000000000..98874c3b80 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/CDOPackageRefTest.java @@ -0,0 +1,153 @@ +package org.eclipse.emf.cdo.tests.hibernate; + +import org.eclipse.emf.cdo.CDOSession; +import org.eclipse.emf.cdo.CDOSessionConfiguration; +import org.eclipse.emf.cdo.CDOTransaction; +import org.eclipse.emf.cdo.server.CDOServerUtil; +import org.eclipse.emf.cdo.server.IRepository; +import org.eclipse.emf.cdo.server.IStore; +import org.eclipse.emf.cdo.server.IRepository.Props; +import org.eclipse.emf.cdo.server.hibernate.teneo.TeneoHibernateMappingProvider; +import org.eclipse.emf.cdo.server.internal.hibernate.HibernateStore; +import org.eclipse.emf.cdo.util.CDOUtil; + +import org.eclipse.net4j.Net4jUtil; +import org.eclipse.net4j.connector.IConnector; +import org.eclipse.net4j.jvm.IJVMAcceptor; +import org.eclipse.net4j.jvm.JVMUtil; +import org.eclipse.net4j.tests.AbstractOMTest; +import org.eclipse.net4j.util.container.ContainerUtil; +import org.eclipse.net4j.util.container.IManagedContainer; +import org.eclipse.net4j.util.lifecycle.LifecycleUtil; + +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.teneo.PersistenceOptions; + +import reference.ReferenceFactory; + +import java.util.HashMap; +import java.util.Map; + +public class CDOPackageRefTest extends AbstractOMTest +{ + private static final String DB_USER = "sa"; + + private static final String DB_PASS = ""; + + private static final String DB_NAME = "mydb"; + + private static final String REPOSITORY_NAME = "repo1"; + + private static final String RESOURCE_PATH = "/my/test/resource"; + + private Resource resource; + + private CDOTransaction transaction; + + private IJVMAcceptor acceptor; + + private IStore store; + + private CDOSession session; + + private IConnector connector; + + private IRepository repository; + + @Override + protected void doSetUp() throws Exception + { + try + { + // LogManager.getLogManager().readConfiguration( + // new FileInputStream("c:\\work\\logging.properties")); + + // IManagedContainer container = IPluginContainer.INSTANCE; + + IManagedContainer container = ContainerUtil.createContainer(); + Net4jUtil.prepareContainer(container); + JVMUtil.prepareContainer(container); + CDOUtil.prepareContainer(container, false); + CDOServerUtil.prepareContainer(container); + + acceptor = JVMUtil.getAcceptor(container, "default"); + store = new HibernateStore(new TeneoHibernateMappingProvider()); + + Map<String, String> props = new HashMap<String, String>(); + props.put(Props.PROP_OVERRIDE_UUID, "f8188187-65de-4c8a-8e75-e0ce5949837a"); + props.put(Props.PROP_SUPPORTING_AUDITS, "false"); + props.put(Props.PROP_SUPPORTING_REVISION_DELTAS, "false"); + props.put(Props.PROP_VERIFYING_REVISIONS, "false"); + props.put(Props.PROP_CURRENT_LRU_CAPACITY, "10000"); + props.put(Props.PROP_REVISED_LRU_CAPACITY, "10000"); + props.put(PersistenceOptions.ID_FEATURE_AS_PRIMARY_KEY, "false"); + props.put("hibernate.connection.autocommit", "true"); + props.put("hibernate.cache.provider_class", "org.hibernate.cache.HashtableCacheProvider"); + props.put("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver"); + props.put("hibernate.connection.url", "jdbc:hsqldb:mem:" + DB_NAME); + props.put("hibernate.connection.username", DB_USER); + props.put("hibernate.connection.password", DB_PASS); + props.put("hibernate.dialect", "org.hibernate.dialect.HSQLDialect"); + props.put("hibernate.hbm2ddl.auto", "update"); + + repository = CDOServerUtil.createRepository(REPOSITORY_NAME, store, props); + CDOServerUtil.addRepository(container, repository); + + connector = JVMUtil.getConnector(container, "default"); + + /* + * case 1: session = CDOUtil.openSession(connector, repositoryName, true, false); + * session.getPackageRegistry().putEPackage(InterfacePackage.eINSTANCE); + * session.getPackageRegistry().putEPackage(ReferencePackage.eINSTANCE); + */ + CDOSessionConfiguration configuration = CDOUtil.createSessionConfiguration(); + configuration.setConnector(connector); + configuration.setRepositoryName(REPOSITORY_NAME); + configuration.setLegacySupportEnabled(false); + + session = configuration.openSession(); + transaction = session.openTransaction(); + resource = transaction.getOrCreateResource(RESOURCE_PATH); + } + catch (Exception e) + { + e.printStackTrace(); + throw e; + } + } + + @Override + protected void doTearDown() throws Exception + { + session.close(); + LifecycleUtil.deactivate(repository); + LifecycleUtil.deactivate(connector); + LifecycleUtil.deactivate(acceptor); + } + + /* + * public void testPutPackage() throws Exception { try { + * session.getPackageRegistry().putEPackage(BasePackage.eINSTANCE); + * session.getPackageRegistry().putEPackage(DerivedPackage.eINSTANCE); transaction.commit(); } catch (Exception e) { + * e.printStackTrace(); throw e; } } public void testPutPackageOneByOne() throws Exception { try { + * session.getPackageRegistry().putEPackage(BasePackage.eINSTANCE); transaction.commit(); + * session.getPackageRegistry().putEPackage(DerivedPackage.eINSTANCE); transaction.commit(); } catch (Exception e) { + * e.printStackTrace(); throw e; } } public void testOnlyBaseData() throws Exception { try { + * resource.getContents().add(BaseFactory.eINSTANCE.createBaseClass()); transaction.commit(); } catch (Exception e) { + * e.printStackTrace(); throw e; } } + */ + + public void testOnlyReference() throws Exception + { + try + { + resource.getContents().add(ReferenceFactory.eINSTANCE.createReference()); + transaction.commit(); + } + catch (Exception e) + { + e.printStackTrace(); + throw e; + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.tests/.classpath b/plugins/org.eclipse.emf.cdo.tests/.classpath index d2d2655389..e7a55df766 100644 --- a/plugins/org.eclipse.emf.cdo.tests/.classpath +++ b/plugins/org.eclipse.emf.cdo.tests/.classpath @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> + <classpathentry kind="src" path="model"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> diff --git a/plugins/org.eclipse.emf.cdo.tests/.settings/.api_filters b/plugins/org.eclipse.emf.cdo.tests/.settings/.api_filters index 28ac20c701..c1ab7d689a 100644 --- a/plugins/org.eclipse.emf.cdo.tests/.settings/.api_filters +++ b/plugins/org.eclipse.emf.cdo.tests/.settings/.api_filters @@ -1,5 +1,14 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <component id="org.eclipse.emf.cdo.tests" version="2"> + <resource path="src/org/eclipse/emf/cdo/tests/store/logic/DBStoreTestLogic.java" type="org.eclipse.emf.cdo.tests.store.logic.DBStoreTestLogic"> + <filter id="627060751"> + <message_arguments> + <message_argument value="DBStore"/> + <message_argument value="DBStoreTestLogic"/> + <message_argument value="store"/> + </message_arguments> + </filter> + </resource> <resource path="src/org/eclipse/emf/cdo/tests/RevisionHolderTest.java" type="org.eclipse.emf.cdo.tests.RevisionHolderTest$RevisionStub"> <filter id="574619656"> <message_arguments> @@ -8,12 +17,19 @@ </message_arguments> </filter> </resource> - <resource path="src/org/eclipse/emf/cdo/tests/store/logic/DBStoreTestLogic.java" type="org.eclipse.emf.cdo.tests.store.logic.DBStoreTestLogic"> - <filter id="627060751"> + <resource path="src/org/eclipse/emf/cdo/tests/RevisionHolderTest.java" type="org.eclipse.emf.cdo.tests.RevisionHolderTest"> + <filter id="576720909"> <message_arguments> - <message_argument value="DBStore"/> - <message_argument value="DBStoreTestLogic"/> - <message_argument value="store"/> + <message_argument value="AbstractOMTest"/> + <message_argument value="RevisionHolderTest"/> + </message_arguments> + </filter> + </resource> + <resource path="src/org/eclipse/emf/cdo/tests/store/logic/TestLogic.java" type="org.eclipse.emf.cdo.tests.store.logic.TestLogic"> + <filter id="576720909"> + <message_arguments> + <message_argument value="AbstractOMTest"/> + <message_argument value="TestLogic"/> </message_arguments> </filter> </resource> @@ -34,4 +50,20 @@ </message_arguments> </filter> </resource> + <resource path="src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java" type="org.eclipse.emf.cdo.tests.AbstractCDOTest"> + <filter id="576720909"> + <message_arguments> + <message_argument value="AbstractTransportTest"/> + <message_argument value="AbstractCDOTest"/> + </message_arguments> + </filter> + </resource> + <resource path="src/org/eclipse/emf/cdo/tests/EMFTest.java" type="org.eclipse.emf.cdo.tests.EMFTest"> + <filter id="576720909"> + <message_arguments> + <message_argument value="AbstractOMTest"/> + <message_argument value="EMFTest"/> + </message_arguments> + </filter> + </resource> </component> diff --git a/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF index 9b0cebe868..55ebcfe22e 100644 --- a/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF @@ -1,6 +1,6 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 -Bundle-SymbolicName: org.eclipse.emf.cdo.tests +Bundle-SymbolicName: org.eclipse.emf.cdo.tests;singleton:=true Bundle-Version: 2.0.0.qualifier Bundle-Name: %pluginName Bundle-Vendor: %providerName @@ -22,6 +22,23 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)", org.eclipse.emf.cdo.tests.model2;bundle-version="[2.0.0,3.0.0)";visibility:=reexport, org.eclipse.emf.cdo.tests.model3;bundle-version="[2.0.0,3.0.0)";visibility:=reexport, org.junit;bundle-version="[3.8.0,4.0.0)";visibility:=reexport -Export-Package: org.eclipse.emf.cdo.tests;version="2.0.0", +Export-Package: base;version="2.0.0", + base.impl;version="2.0.0", + base.util;version="2.0.0", + derived;version="2.0.0", + derived.impl;version="2.0.0", + derived.util;version="2.0.0", + interface_;version="2.0.0", + interface_.impl;version="2.0.0", + interface_.util;version="2.0.0", + org.eclipse.emf.cdo.tests;version="2.0.0", org.eclipse.emf.cdo.tests.store.logic;version="2.0.0", - org.eclipse.net4j.tests;version="2.0.0" + org.eclipse.net4j.tests;version="2.0.0";x-friends:="org.eclipse.emf.cdo.tests.hibernate,org.eclipse.emf.cdo.tests.hibernate.client", + reference;version="2.0.0", + reference.impl;version="2.0.0", + reference.util;version="2.0.0" +Import-Package: org.apache.commons.collections;version="[3.2.0,4.0.0)", + org.apache.commons.logging;version="[1.1.0,2.0.0)", + org.dom4j;version="[1.6.0,2.0.0)", + org.hsqldb;version="[1.8.0,2.0.0)", + org.hsqldb.jdbc;version="[1.8.0,2.0.0)" diff --git a/plugins/org.eclipse.emf.cdo.tests/build.properties b/plugins/org.eclipse.emf.cdo.tests/build.properties index 10d675bf01..93ddf1567b 100644 --- a/plugins/org.eclipse.emf.cdo.tests/build.properties +++ b/plugins/org.eclipse.emf.cdo.tests/build.properties @@ -1,31 +1,33 @@ -# Copyright (c) 2004 - 2008 Eike Stepper, Germany. -# 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: -# Eike Stepper - initial API and implementation - -# NLS_MESSAGEFORMAT_VAR -source.. = src/,\ - net4j/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - about.html,\ - copyright.txt,\ - epl-v10.html,\ - license.html,\ +# <copyright> +# </copyright> +# +# $Id$ + +bin.includes = .,\ + model/,\ + META-INF/,\ + plugin.xml,\ plugin.properties,\ - model2.ecore,\ - model1.ecore,\ - ecore/,\ - uml2/,\ - test.xml,\ + CDO AllTests.launch,\ + HSQLDBHorizontalTest.java,\ + copyright.txt,\ + about.html,\ about.ini,\ about.mappings,\ about.properties,\ - My.ecore,\ - modeling32.png + defs/,\ + ecore/,\ + license.html,\ + epl-v10.html,\ + model1.ecore,\ + modeling32.png,\ + model2.ecore,\ + test.xml,\ + uml2/,\ + My.ecore +jars.compile.order = . +source.. = src/,\ + model/,\ + net4j/ +output.. = bin/ diff --git a/plugins/org.eclipse.emf.cdo.tests/model/base.ecore b/plugins/org.eclipse.emf.cdo.tests/model/base.ecore new file mode 100644 index 0000000000..577da4fad5 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/base.ecore @@ -0,0 +1,10 @@ +<?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="base" + nsURI="http://www.fernuni-hagen.de/ST/dummy/base.ecore" nsPrefix="base"> + <eClassifiers xsi:type="ecore:EClass" name="BaseClass"> + <eOperations name="increment"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="couter" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/> + </eClassifiers> +</ecore:EPackage> diff --git a/plugins/org.eclipse.emf.cdo.tests/model/base.genmodel b/plugins/org.eclipse.emf.cdo.tests/model/base.genmodel new file mode 100644 index 0000000000..5f23be05f8 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/base.genmodel @@ -0,0 +1,18 @@ +<?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" modelDirectory="/org.eclipse.emf.cdo.tests/model" + editDirectory="" editorDirectory="" modelPluginID="org.eclipse.emf.cdo.tests" + modelName="Base" updateClasspath="false" rootExtendsInterface="org.eclipse.emf.cdo.CDOObject" + rootExtendsClass="org.eclipse.emf.internal.cdo.CDOObjectImpl" reflectiveDelegation="true" + codeFormatting="true" testsDirectory="" importerID="org.eclipse.emf.importer.cdo" + featureDelegation="Reflective" complianceLevel="5.0" copyrightFields="false"> + <foreignModel>base.ecore</foreignModel> + <modelPluginVariables>CDO=org.eclipse.emf.cdo</modelPluginVariables> + <genPackages prefix="Base" disposableProviderFactory="true" ecorePackage="base.ecore#/"> + <genClasses ecoreClass="base.ecore#//BaseClass"> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute base.ecore#//BaseClass/couter"/> + <genOperations ecoreOperation="base.ecore#//BaseClass/increment"/> + </genClasses> + </genPackages> +</genmodel:GenModel> diff --git a/plugins/org.eclipse.emf.cdo.tests/model/base/BaseClass.java b/plugins/org.eclipse.emf.cdo.tests/model/base/BaseClass.java new file mode 100644 index 0000000000..40f9454c0a --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/base/BaseClass.java @@ -0,0 +1,61 @@ +/** + * <copyright> + * </copyright> + * + * $Id: BaseClass.java,v 1.1 2008-07-02 14:09:48 estepper Exp $ + */ +package base; + +import org.eclipse.emf.cdo.CDOObject; + +/** + * <!-- 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 base.BaseClass#getCouter <em>Couter</em>}</li> + * </ul> + * </p> + * + * @see base.BasePackage#getBaseClass() + * @model + * @extends CDOObject + * @generated + */ +public interface BaseClass extends CDOObject +{ + /** + * Returns the value of the '<em><b>Couter</b></em>' attribute. <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Couter</em>' attribute isn't clear, there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * + * @return the value of the '<em>Couter</em>' attribute. + * @see #setCouter(int) + * @see base.BasePackage#getBaseClass_Couter() + * @model + * @generated + */ + int getCouter(); + + /** + * Sets the value of the '{@link base.BaseClass#getCouter <em>Couter</em>}' attribute. <!-- begin-user-doc --> <!-- + * end-user-doc --> + * + * @param value + * the new value of the '<em>Couter</em>' attribute. + * @see #getCouter() + * @generated + */ + void setCouter(int value); + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @model + * @generated + */ + void increment(); + +} // BaseClass diff --git a/plugins/org.eclipse.emf.cdo.tests/model/base/BaseFactory.java b/plugins/org.eclipse.emf.cdo.tests/model/base/BaseFactory.java new file mode 100644 index 0000000000..a8ed29eebe --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/base/BaseFactory.java @@ -0,0 +1,43 @@ +/** + * <copyright> + * </copyright> + * + * $Id: BaseFactory.java,v 1.1 2008-07-02 14:09:48 estepper Exp $ + */ +package base; + +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 base.BasePackage + * @generated + */ +public interface BaseFactory extends EFactory +{ + /** + * The singleton instance of the factory. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + BaseFactory eINSTANCE = base.impl.BaseFactoryImpl.init(); + + /** + * 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 + */ + BaseClass createBaseClass(); + + /** + * Returns the package supported by this factory. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @return the package supported by this factory. + * @generated + */ + BasePackage getBasePackage(); + +} // BaseFactory diff --git a/plugins/org.eclipse.emf.cdo.tests/model/base/BasePackage.java b/plugins/org.eclipse.emf.cdo.tests/model/base/BasePackage.java new file mode 100644 index 0000000000..73ba6f448d --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/base/BasePackage.java @@ -0,0 +1,146 @@ +/** + * <copyright> + * </copyright> + * + * $Id: BasePackage.java,v 1.1 2008-07-02 14:09:48 estepper Exp $ + */ +package base; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; + +/** + * <!-- 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 enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * + * @see base.BaseFactory + * @model kind="package" + * @generated + */ +public interface BasePackage extends EPackage +{ + /** + * The package name. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + String eNAME = "base"; + + /** + * The package namespace URI. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + String eNS_URI = "http://www.fernuni-hagen.de/ST/dummy/base.ecore"; + + /** + * The package namespace name. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + String eNS_PREFIX = "base"; + + /** + * The singleton instance of the package. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + BasePackage eINSTANCE = base.impl.BasePackageImpl.init(); + + /** + * The meta object id for the '{@link base.impl.BaseClassImpl <em>Class</em>}' class. <!-- begin-user-doc --> <!-- + * end-user-doc --> + * + * @see base.impl.BaseClassImpl + * @see base.impl.BasePackageImpl#getBaseClass() + * @generated + */ + int BASE_CLASS = 0; + + /** + * The feature id for the '<em><b>Couter</b></em>' attribute. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + * @ordered + */ + int BASE_CLASS__COUTER = 0; + + /** + * The number of structural features of the '<em>Class</em>' class. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + * @ordered + */ + int BASE_CLASS_FEATURE_COUNT = 1; + + /** + * Returns the meta object for class '{@link base.BaseClass <em>Class</em>}'. <!-- begin-user-doc --> <!-- + * end-user-doc --> + * + * @return the meta object for class '<em>Class</em>'. + * @see base.BaseClass + * @generated + */ + EClass getBaseClass(); + + /** + * Returns the meta object for the attribute '{@link base.BaseClass#getCouter <em>Couter</em>}'. <!-- begin-user-doc + * --> <!-- end-user-doc --> + * + * @return the meta object for the attribute '<em>Couter</em>'. + * @see base.BaseClass#getCouter() + * @see #getBaseClass() + * @generated + */ + EAttribute getBaseClass_Couter(); + + /** + * 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 + */ + BaseFactory getBaseFactory(); + + /** + * <!-- 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 enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * + * @generated + */ + interface Literals + { + /** + * The meta object literal for the '{@link base.impl.BaseClassImpl <em>Class</em>}' class. <!-- begin-user-doc --> + * <!-- end-user-doc --> + * + * @see base.impl.BaseClassImpl + * @see base.impl.BasePackageImpl#getBaseClass() + * @generated + */ + EClass BASE_CLASS = eINSTANCE.getBaseClass(); + + /** + * The meta object literal for the '<em><b>Couter</b></em>' attribute feature. <!-- begin-user-doc --> <!-- + * end-user-doc --> + * + * @generated + */ + EAttribute BASE_CLASS__COUTER = eINSTANCE.getBaseClass_Couter(); + + } + +} // BasePackage diff --git a/plugins/org.eclipse.emf.cdo.tests/model/base/impl/BaseClassImpl.java b/plugins/org.eclipse.emf.cdo.tests/model/base/impl/BaseClassImpl.java new file mode 100644 index 0000000000..e23e654092 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/base/impl/BaseClassImpl.java @@ -0,0 +1,93 @@ +/** + * <copyright> + * </copyright> + * + * $Id: BaseClassImpl.java,v 1.1 2008-07-02 14:09:49 estepper Exp $ + */ +package base.impl; + +import org.eclipse.emf.internal.cdo.CDOObjectImpl; + +import org.eclipse.emf.ecore.EClass; + +import base.BaseClass; +import base.BasePackage; + +/** + * <!-- 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 base.impl.BaseClassImpl#getCouter <em>Couter</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class BaseClassImpl extends CDOObjectImpl implements BaseClass +{ + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + protected BaseClassImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + @Override + protected EClass eStaticClass() + { + return BasePackage.Literals.BASE_CLASS; + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + @Override + protected int eStaticFeatureCount() + { + return 0; + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public int getCouter() + { + return ((Integer)eGet(BasePackage.Literals.BASE_CLASS__COUTER, true)).intValue(); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public void setCouter(int newCouter) + { + eSet(BasePackage.Literals.BASE_CLASS__COUTER, new Integer(newCouter)); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public void increment() + { + // TODO: implement this method + // Ensure that you remove @generated or mark it @generated NOT + throw new UnsupportedOperationException(); + } + +} // BaseClassImpl diff --git a/plugins/org.eclipse.emf.cdo.tests/model/base/impl/BaseFactoryImpl.java b/plugins/org.eclipse.emf.cdo.tests/model/base/impl/BaseFactoryImpl.java new file mode 100644 index 0000000000..522f3d710a --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/base/impl/BaseFactoryImpl.java @@ -0,0 +1,109 @@ +/** + * <copyright> + * </copyright> + * + * $Id: BaseFactoryImpl.java,v 1.1 2008-07-02 14:09:49 estepper Exp $ + */ +package base.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 base.BaseClass; +import base.BaseFactory; +import base.BasePackage; + +/** + * <!-- begin-user-doc --> An implementation of the model <b>Factory</b>. <!-- end-user-doc --> + * + * @generated + */ +public class BaseFactoryImpl extends EFactoryImpl implements BaseFactory +{ + /** + * Creates the default factory implementation. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public static BaseFactory init() + { + try + { + BaseFactory theBaseFactory = (BaseFactory)EPackage.Registry.INSTANCE + .getEFactory("http://www.fernuni-hagen.de/ST/dummy/base.ecore"); + if (theBaseFactory != null) + { + return theBaseFactory; + } + } + catch (Exception exception) + { + EcorePlugin.INSTANCE.log(exception); + } + return new BaseFactoryImpl(); + } + + /** + * Creates an instance of the factory. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public BaseFactoryImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + @Override + public EObject create(EClass eClass) + { + switch (eClass.getClassifierID()) + { + case BasePackage.BASE_CLASS: + return (EObject)createBaseClass(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public BaseClass createBaseClass() + { + BaseClassImpl baseClass = new BaseClassImpl(); + return baseClass; + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public BasePackage getBasePackage() + { + return (BasePackage)getEPackage(); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @deprecated + * @generated + */ + @Deprecated + public static BasePackage getPackage() + { + return BasePackage.eINSTANCE; + } + +} // BaseFactoryImpl diff --git a/plugins/org.eclipse.emf.cdo.tests/model/base/impl/BasePackageImpl.java b/plugins/org.eclipse.emf.cdo.tests/model/base/impl/BasePackageImpl.java new file mode 100644 index 0000000000..4cdc199ffb --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/base/impl/BasePackageImpl.java @@ -0,0 +1,191 @@ +/** + * <copyright> + * </copyright> + * + * $Id: BasePackageImpl.java,v 1.1 2008-07-02 14:09:49 estepper Exp $ + */ +package base.impl; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.impl.EPackageImpl; + +import base.BaseClass; +import base.BaseFactory; +import base.BasePackage; + +/** + * <!-- begin-user-doc --> An implementation of the model <b>Package</b>. <!-- end-user-doc --> + * + * @generated + */ +public class BasePackageImpl extends EPackageImpl implements BasePackage +{ + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + private EClass baseClassEClass = 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 base.BasePackage#eNS_URI + * @see #init() + * @generated + */ + private BasePackageImpl() + { + super(eNS_URI, BaseFactory.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. + * Simple dependencies are satisfied by calling this method on all dependent packages before doing anything else. This + * method drives initialization for interdependent packages directly, in parallel with this package, itself. + * <p> + * Of this package and its interdependencies, all packages which have not yet been registered by their URI values are + * first created and registered. The packages are then initialized in two steps: meta-model objects for all of the + * packages are created before any are initialized, since one package's meta-model objects may refer to those of + * another. + * <p> + * Invocation of this method will not affect any packages that have already been initialized. <!-- begin-user-doc --> + * <!-- end-user-doc --> + * + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static BasePackage init() + { + if (isInited) return (BasePackage)EPackage.Registry.INSTANCE.getEPackage(BasePackage.eNS_URI); + + // Obtain or create and register package + BasePackageImpl theBasePackage = (BasePackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof BasePackageImpl ? EPackage.Registry.INSTANCE + .getEPackage(eNS_URI) + : new BasePackageImpl()); + + isInited = true; + + // Create package meta-data objects + theBasePackage.createPackageContents(); + + // Initialize created meta-data + theBasePackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theBasePackage.freeze(); + + return theBasePackage; + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public EClass getBaseClass() + { + return baseClassEClass; + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public EAttribute getBaseClass_Couter() + { + return (EAttribute)baseClassEClass.getEStructuralFeatures().get(0); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public BaseFactory getBaseFactory() + { + return (BaseFactory)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 + baseClassEClass = createEClass(BASE_CLASS); + createEAttribute(baseClassEClass, BASE_CLASS__COUTER); + } + + /** + * <!-- 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 + + // Initialize classes and features; add operations and parameters + initEClass(baseClassEClass, BaseClass.class, "BaseClass", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getBaseClass_Couter(), ecorePackage.getEInt(), "couter", null, 0, 1, BaseClass.class, !IS_TRANSIENT, + !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + addEOperation(baseClassEClass, null, "increment", 0, 1, IS_UNIQUE, IS_ORDERED); + + // Create resource + createResource(eNS_URI); + } + +} // BasePackageImpl diff --git a/plugins/org.eclipse.emf.cdo.tests/model/base/util/BaseAdapterFactory.java b/plugins/org.eclipse.emf.cdo.tests/model/base/util/BaseAdapterFactory.java new file mode 100644 index 0000000000..a32ca6e1fe --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/base/util/BaseAdapterFactory.java @@ -0,0 +1,128 @@ +/** + * <copyright> + * </copyright> + * + * $Id: BaseAdapterFactory.java,v 1.1 2008-07-02 14:09:48 estepper Exp $ + */ +package base.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 base.BaseClass; +import base.BasePackage; + +/** + * <!-- 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 base.BasePackage + * @generated + */ +public class BaseAdapterFactory extends AdapterFactoryImpl +{ + /** + * The cached model package. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + protected static BasePackage modelPackage; + + /** + * Creates an instance of the adapter factory. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public BaseAdapterFactory() + { + if (modelPackage == null) + { + modelPackage = BasePackage.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 BaseSwitch<Adapter> modelSwitch = new BaseSwitch<Adapter>() + { + @Override + public Adapter caseBaseClass(BaseClass object) + { + return createBaseClassAdapter(); + } + + @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 base.BaseClass <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 base.BaseClass + * @generated + */ + public Adapter createBaseClassAdapter() + { + 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; + } + +} // BaseAdapterFactory diff --git a/plugins/org.eclipse.emf.cdo.tests/model/base/util/BaseSwitch.java b/plugins/org.eclipse.emf.cdo.tests/model/base/util/BaseSwitch.java new file mode 100644 index 0000000000..258ed5cd67 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/base/util/BaseSwitch.java @@ -0,0 +1,134 @@ +/** + * <copyright> + * </copyright> + * + * $Id: BaseSwitch.java,v 1.1 2008-07-02 14:09:48 estepper Exp $ + */ +package base.util; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; + +import base.BaseClass; +import base.BasePackage; + +import java.util.List; + +/** + * <!-- 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 base.BasePackage + * @generated + */ +public class BaseSwitch<T> +{ + /** + * The cached model package <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + protected static BasePackage modelPackage; + + /** + * Creates an instance of the switch. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public BaseSwitch() + { + if (modelPackage == null) + { + modelPackage = BasePackage.eINSTANCE; + } + } + + /** + * 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 + */ + public T doSwitch(EObject theEObject) + { + return doSwitch(theEObject.eClass(), theEObject); + } + + /** + * 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 + */ + protected T doSwitch(EClass theEClass, EObject theEObject) + { + if (theEClass.eContainer() == modelPackage) + { + return doSwitch(theEClass.getClassifierID(), theEObject); + } + else + { + List<EClass> eSuperTypes = theEClass.getESuperTypes(); + return eSuperTypes.isEmpty() ? defaultCase(theEObject) : doSwitch(eSuperTypes.get(0), theEObject); + } + } + + /** + * 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 + */ + protected T doSwitch(int classifierID, EObject theEObject) + { + switch (classifierID) + { + case BasePackage.BASE_CLASS: + { + BaseClass baseClass = (BaseClass)theEObject; + T result = caseBaseClass(baseClass); + if (result == null) result = defaultCase(theEObject); + return result; + } + default: + return defaultCase(theEObject); + } + } + + /** + * 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 caseBaseClass(BaseClass 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 + */ + public T defaultCase(EObject object) + { + return null; + } + +} // BaseSwitch diff --git a/plugins/org.eclipse.emf.cdo.tests/model/derived.ecore b/plugins/org.eclipse.emf.cdo.tests/model/derived.ecore new file mode 100644 index 0000000000..261071e0e8 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/derived.ecore @@ -0,0 +1,9 @@ +<?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="derived" + nsURI="http://www.fernuni-hagen.de/ST/dummy/derived.ecore" nsPrefix="derived"> + <eClassifiers xsi:type="ecore:EClass" name="DerivedClass" eSuperTypes="base.ecore#//BaseClass"> + <eOperations name="decrement"/> + </eClassifiers> +</ecore:EPackage> diff --git a/plugins/org.eclipse.emf.cdo.tests/model/derived.genmodel b/plugins/org.eclipse.emf.cdo.tests/model/derived.genmodel new file mode 100644 index 0000000000..4bdc819f95 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/derived.genmodel @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<genmodel:GenModel xmi:version="2.0" + xmlns:xmi="http://www.omg.org/XMI" xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/org.eclipse.emf.cdo.tests/model" + editDirectory="" editorDirectory="" modelPluginID="org.eclipse.emf.cdo.tests" + modelName="Derived" updateClasspath="false" rootExtendsInterface="org.eclipse.emf.cdo.CDOObject" + rootExtendsClass="org.eclipse.emf.internal.cdo.CDOObjectImpl" reflectiveDelegation="true" + codeFormatting="true" testsDirectory="" importerID="org.eclipse.emf.importer.cdo" + featureDelegation="Reflective" complianceLevel="5.0" copyrightFields="false" usedGenPackages="base.genmodel#//base"> + <foreignModel>derived.ecore</foreignModel> + <modelPluginVariables>CDO=org.eclipse.emf.cdo</modelPluginVariables> + <genPackages prefix="Derived" disposableProviderFactory="true" ecorePackage="derived.ecore#/"> + <genClasses ecoreClass="derived.ecore#//DerivedClass"> + <genOperations ecoreOperation="derived.ecore#//DerivedClass/decrement"/> + </genClasses> + </genPackages> +</genmodel:GenModel> diff --git a/plugins/org.eclipse.emf.cdo.tests/model/derived/DerivedClass.java b/plugins/org.eclipse.emf.cdo.tests/model/derived/DerivedClass.java new file mode 100644 index 0000000000..d5e5d38d48 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/derived/DerivedClass.java @@ -0,0 +1,28 @@ +/** + * <copyright> + * </copyright> + * + * $Id: DerivedClass.java,v 1.1 2008-07-02 14:09:48 estepper Exp $ + */ +package derived; + +import base.BaseClass; + +/** + * <!-- begin-user-doc --> A representation of the model object '<em><b>Class</b></em>'. <!-- end-user-doc --> + * + * @see derived.DerivedPackage#getDerivedClass() + * @model + * @generated + */ +public interface DerivedClass extends BaseClass +{ + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @model + * @generated + */ + void decrement(); + +} // DerivedClass diff --git a/plugins/org.eclipse.emf.cdo.tests/model/derived/DerivedFactory.java b/plugins/org.eclipse.emf.cdo.tests/model/derived/DerivedFactory.java new file mode 100644 index 0000000000..8009db63d0 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/derived/DerivedFactory.java @@ -0,0 +1,43 @@ +/** + * <copyright> + * </copyright> + * + * $Id: DerivedFactory.java,v 1.1 2008-07-02 14:09:48 estepper Exp $ + */ +package derived; + +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 derived.DerivedPackage + * @generated + */ +public interface DerivedFactory extends EFactory +{ + /** + * The singleton instance of the factory. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + DerivedFactory eINSTANCE = derived.impl.DerivedFactoryImpl.init(); + + /** + * 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 + */ + DerivedClass createDerivedClass(); + + /** + * Returns the package supported by this factory. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @return the package supported by this factory. + * @generated + */ + DerivedPackage getDerivedPackage(); + +} // DerivedFactory diff --git a/plugins/org.eclipse.emf.cdo.tests/model/derived/DerivedPackage.java b/plugins/org.eclipse.emf.cdo.tests/model/derived/DerivedPackage.java new file mode 100644 index 0000000000..6b346280fa --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/derived/DerivedPackage.java @@ -0,0 +1,128 @@ +/** + * <copyright> + * </copyright> + * + * $Id: DerivedPackage.java,v 1.1 2008-07-02 14:09:48 estepper Exp $ + */ +package derived; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; + +import base.BasePackage; + +/** + * <!-- 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 enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * + * @see derived.DerivedFactory + * @model kind="package" + * @generated + */ +public interface DerivedPackage extends EPackage +{ + /** + * The package name. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + String eNAME = "derived"; + + /** + * The package namespace URI. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + String eNS_URI = "http://www.fernuni-hagen.de/ST/dummy/derived.ecore"; + + /** + * The package namespace name. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + String eNS_PREFIX = "derived"; + + /** + * The singleton instance of the package. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + DerivedPackage eINSTANCE = derived.impl.DerivedPackageImpl.init(); + + /** + * The meta object id for the '{@link derived.impl.DerivedClassImpl <em>Class</em>}' class. <!-- begin-user-doc --> + * <!-- end-user-doc --> + * + * @see derived.impl.DerivedClassImpl + * @see derived.impl.DerivedPackageImpl#getDerivedClass() + * @generated + */ + int DERIVED_CLASS = 0; + + /** + * The feature id for the '<em><b>Couter</b></em>' attribute. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + * @ordered + */ + int DERIVED_CLASS__COUTER = BasePackage.BASE_CLASS__COUTER; + + /** + * The number of structural features of the '<em>Class</em>' class. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + * @ordered + */ + int DERIVED_CLASS_FEATURE_COUNT = BasePackage.BASE_CLASS_FEATURE_COUNT + 0; + + /** + * Returns the meta object for class '{@link derived.DerivedClass <em>Class</em>}'. <!-- begin-user-doc --> <!-- + * end-user-doc --> + * + * @return the meta object for class '<em>Class</em>'. + * @see derived.DerivedClass + * @generated + */ + EClass getDerivedClass(); + + /** + * 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 + */ + DerivedFactory getDerivedFactory(); + + /** + * <!-- 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 enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * + * @generated + */ + interface Literals + { + /** + * The meta object literal for the '{@link derived.impl.DerivedClassImpl <em>Class</em>}' class. <!-- begin-user-doc + * --> <!-- end-user-doc --> + * + * @see derived.impl.DerivedClassImpl + * @see derived.impl.DerivedPackageImpl#getDerivedClass() + * @generated + */ + EClass DERIVED_CLASS = eINSTANCE.getDerivedClass(); + + } + +} // DerivedPackage diff --git a/plugins/org.eclipse.emf.cdo.tests/model/derived/impl/DerivedClassImpl.java b/plugins/org.eclipse.emf.cdo.tests/model/derived/impl/DerivedClassImpl.java new file mode 100644 index 0000000000..0ac59a6a2e --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/derived/impl/DerivedClassImpl.java @@ -0,0 +1,57 @@ +/** + * <copyright> + * </copyright> + * + * $Id: DerivedClassImpl.java,v 1.1 2008-07-02 14:09:49 estepper Exp $ + */ +package derived.impl; + +import org.eclipse.emf.ecore.EClass; + +import base.impl.BaseClassImpl; +import derived.DerivedClass; +import derived.DerivedPackage; + +/** + * <!-- begin-user-doc --> An implementation of the model object '<em><b>Class</b></em>'. <!-- end-user-doc --> + * <p> + * </p> + * + * @generated + */ +public class DerivedClassImpl extends BaseClassImpl implements DerivedClass +{ + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + protected DerivedClassImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + @Override + protected EClass eStaticClass() + { + return DerivedPackage.Literals.DERIVED_CLASS; + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public void decrement() + { + // TODO: implement this method + // Ensure that you remove @generated or mark it @generated NOT + throw new UnsupportedOperationException(); + } + +} // DerivedClassImpl diff --git a/plugins/org.eclipse.emf.cdo.tests/model/derived/impl/DerivedFactoryImpl.java b/plugins/org.eclipse.emf.cdo.tests/model/derived/impl/DerivedFactoryImpl.java new file mode 100644 index 0000000000..dfb3c95f80 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/derived/impl/DerivedFactoryImpl.java @@ -0,0 +1,109 @@ +/** + * <copyright> + * </copyright> + * + * $Id: DerivedFactoryImpl.java,v 1.1 2008-07-02 14:09:49 estepper Exp $ + */ +package derived.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 derived.DerivedClass; +import derived.DerivedFactory; +import derived.DerivedPackage; + +/** + * <!-- begin-user-doc --> An implementation of the model <b>Factory</b>. <!-- end-user-doc --> + * + * @generated + */ +public class DerivedFactoryImpl extends EFactoryImpl implements DerivedFactory +{ + /** + * Creates the default factory implementation. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public static DerivedFactory init() + { + try + { + DerivedFactory theDerivedFactory = (DerivedFactory)EPackage.Registry.INSTANCE + .getEFactory("http://www.fernuni-hagen.de/ST/dummy/derived.ecore"); + if (theDerivedFactory != null) + { + return theDerivedFactory; + } + } + catch (Exception exception) + { + EcorePlugin.INSTANCE.log(exception); + } + return new DerivedFactoryImpl(); + } + + /** + * Creates an instance of the factory. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public DerivedFactoryImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + @Override + public EObject create(EClass eClass) + { + switch (eClass.getClassifierID()) + { + case DerivedPackage.DERIVED_CLASS: + return (EObject)createDerivedClass(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public DerivedClass createDerivedClass() + { + DerivedClassImpl derivedClass = new DerivedClassImpl(); + return derivedClass; + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public DerivedPackage getDerivedPackage() + { + return (DerivedPackage)getEPackage(); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @deprecated + * @generated + */ + @Deprecated + public static DerivedPackage getPackage() + { + return DerivedPackage.eINSTANCE; + } + +} // DerivedFactoryImpl diff --git a/plugins/org.eclipse.emf.cdo.tests/model/derived/impl/DerivedPackageImpl.java b/plugins/org.eclipse.emf.cdo.tests/model/derived/impl/DerivedPackageImpl.java new file mode 100644 index 0000000000..ba311836b2 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/derived/impl/DerivedPackageImpl.java @@ -0,0 +1,186 @@ +/** + * <copyright> + * </copyright> + * + * $Id: DerivedPackageImpl.java,v 1.1 2008-07-02 14:09:49 estepper Exp $ + */ +package derived.impl; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.impl.EPackageImpl; + +import base.BasePackage; +import derived.DerivedClass; +import derived.DerivedFactory; +import derived.DerivedPackage; + +/** + * <!-- begin-user-doc --> An implementation of the model <b>Package</b>. <!-- end-user-doc --> + * + * @generated + */ +public class DerivedPackageImpl extends EPackageImpl implements DerivedPackage +{ + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + private EClass derivedClassEClass = 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 derived.DerivedPackage#eNS_URI + * @see #init() + * @generated + */ + private DerivedPackageImpl() + { + super(eNS_URI, DerivedFactory.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. + * Simple dependencies are satisfied by calling this method on all dependent packages before doing anything else. This + * method drives initialization for interdependent packages directly, in parallel with this package, itself. + * <p> + * Of this package and its interdependencies, all packages which have not yet been registered by their URI values are + * first created and registered. The packages are then initialized in two steps: meta-model objects for all of the + * packages are created before any are initialized, since one package's meta-model objects may refer to those of + * another. + * <p> + * Invocation of this method will not affect any packages that have already been initialized. <!-- begin-user-doc --> + * <!-- end-user-doc --> + * + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static DerivedPackage init() + { + if (isInited) return (DerivedPackage)EPackage.Registry.INSTANCE.getEPackage(DerivedPackage.eNS_URI); + + // Obtain or create and register package + DerivedPackageImpl theDerivedPackage = (DerivedPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof DerivedPackageImpl ? EPackage.Registry.INSTANCE + .getEPackage(eNS_URI) + : new DerivedPackageImpl()); + + isInited = true; + + // Initialize simple dependencies + BasePackage.eINSTANCE.eClass(); + + // Create package meta-data objects + theDerivedPackage.createPackageContents(); + + // Initialize created meta-data + theDerivedPackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theDerivedPackage.freeze(); + + return theDerivedPackage; + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public EClass getDerivedClass() + { + return derivedClassEClass; + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public DerivedFactory getDerivedFactory() + { + return (DerivedFactory)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 + derivedClassEClass = createEClass(DERIVED_CLASS); + } + + /** + * <!-- 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); + + // Obtain other dependent packages + BasePackage theBasePackage = (BasePackage)EPackage.Registry.INSTANCE.getEPackage(BasePackage.eNS_URI); + + // Create type parameters + + // Set bounds for type parameters + + // Add supertypes to classes + derivedClassEClass.getESuperTypes().add(theBasePackage.getBaseClass()); + + // Initialize classes and features; add operations and parameters + initEClass(derivedClassEClass, DerivedClass.class, "DerivedClass", !IS_ABSTRACT, !IS_INTERFACE, + IS_GENERATED_INSTANCE_CLASS); + + addEOperation(derivedClassEClass, null, "decrement", 0, 1, IS_UNIQUE, IS_ORDERED); + + // Create resource + createResource(eNS_URI); + } + +} // DerivedPackageImpl diff --git a/plugins/org.eclipse.emf.cdo.tests/model/derived/util/DerivedAdapterFactory.java b/plugins/org.eclipse.emf.cdo.tests/model/derived/util/DerivedAdapterFactory.java new file mode 100644 index 0000000000..d01bdb36a1 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/derived/util/DerivedAdapterFactory.java @@ -0,0 +1,149 @@ +/** + * <copyright> + * </copyright> + * + * $Id: DerivedAdapterFactory.java,v 1.1 2008-07-02 14:09:49 estepper Exp $ + */ +package derived.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 base.BaseClass; +import derived.DerivedClass; +import derived.DerivedPackage; + +/** + * <!-- 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 derived.DerivedPackage + * @generated + */ +public class DerivedAdapterFactory extends AdapterFactoryImpl +{ + /** + * The cached model package. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + protected static DerivedPackage modelPackage; + + /** + * Creates an instance of the adapter factory. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public DerivedAdapterFactory() + { + if (modelPackage == null) + { + modelPackage = DerivedPackage.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 DerivedSwitch<Adapter> modelSwitch = new DerivedSwitch<Adapter>() + { + @Override + public Adapter caseDerivedClass(DerivedClass object) + { + return createDerivedClassAdapter(); + } + + @Override + public Adapter caseBaseClass(BaseClass object) + { + return createBaseClassAdapter(); + } + + @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 derived.DerivedClass <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 derived.DerivedClass + * @generated + */ + public Adapter createDerivedClassAdapter() + { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link base.BaseClass <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 base.BaseClass + * @generated + */ + public Adapter createBaseClassAdapter() + { + 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; + } + +} // DerivedAdapterFactory diff --git a/plugins/org.eclipse.emf.cdo.tests/model/derived/util/DerivedSwitch.java b/plugins/org.eclipse.emf.cdo.tests/model/derived/util/DerivedSwitch.java new file mode 100644 index 0000000000..77fc6e3b87 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/derived/util/DerivedSwitch.java @@ -0,0 +1,151 @@ +/** + * <copyright> + * </copyright> + * + * $Id: DerivedSwitch.java,v 1.1 2008-07-02 14:09:49 estepper Exp $ + */ +package derived.util; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; + +import base.BaseClass; +import derived.DerivedClass; +import derived.DerivedPackage; + +import java.util.List; + +/** + * <!-- 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 derived.DerivedPackage + * @generated + */ +public class DerivedSwitch<T> +{ + /** + * The cached model package <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + protected static DerivedPackage modelPackage; + + /** + * Creates an instance of the switch. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public DerivedSwitch() + { + if (modelPackage == null) + { + modelPackage = DerivedPackage.eINSTANCE; + } + } + + /** + * 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 + */ + public T doSwitch(EObject theEObject) + { + return doSwitch(theEObject.eClass(), theEObject); + } + + /** + * 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 + */ + protected T doSwitch(EClass theEClass, EObject theEObject) + { + if (theEClass.eContainer() == modelPackage) + { + return doSwitch(theEClass.getClassifierID(), theEObject); + } + else + { + List<EClass> eSuperTypes = theEClass.getESuperTypes(); + return eSuperTypes.isEmpty() ? defaultCase(theEObject) : doSwitch(eSuperTypes.get(0), theEObject); + } + } + + /** + * 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 + */ + protected T doSwitch(int classifierID, EObject theEObject) + { + switch (classifierID) + { + case DerivedPackage.DERIVED_CLASS: + { + DerivedClass derivedClass = (DerivedClass)theEObject; + T result = caseDerivedClass(derivedClass); + if (result == null) result = caseBaseClass(derivedClass); + if (result == null) result = defaultCase(theEObject); + return result; + } + default: + return defaultCase(theEObject); + } + } + + /** + * 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 caseDerivedClass(DerivedClass 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 caseBaseClass(BaseClass 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 + */ + public T defaultCase(EObject object) + { + return null; + } + +} // DerivedSwitch diff --git a/plugins/org.eclipse.emf.cdo.tests/model/interface.ecore b/plugins/org.eclipse.emf.cdo.tests/model/interface.ecore new file mode 100644 index 0000000000..465bcaa5e9 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/interface.ecore @@ -0,0 +1,9 @@ +<?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="interface" + nsURI="uuid://interface" nsPrefix="interface"> + <eClassifiers xsi:type="ecore:EClass" name="IInterface" abstract="true" interface="true"> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="test" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> + </eClassifiers> +</ecore:EPackage> diff --git a/plugins/org.eclipse.emf.cdo.tests/model/interface.genmodel b/plugins/org.eclipse.emf.cdo.tests/model/interface.genmodel new file mode 100644 index 0000000000..cc93e75f7c --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/interface.genmodel @@ -0,0 +1,17 @@ +<?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" modelDirectory="/org.eclipse.emf.cdo.tests/model" + editDirectory="" editorDirectory="" modelPluginID="org.eclipse.emf.cdo.tests" + modelName="Interface" updateClasspath="false" rootExtendsInterface="org.eclipse.emf.cdo.CDOObject" + rootExtendsClass="org.eclipse.emf.internal.cdo.CDOObjectImpl" reflectiveDelegation="true" + codeFormatting="true" testsDirectory="" importerID="org.eclipse.emf.importer.cdo" + featureDelegation="Reflective" complianceLevel="5.0" copyrightFields="false"> + <foreignModel>interface.ecore</foreignModel> + <modelPluginVariables>CDO=org.eclipse.emf.cdo</modelPluginVariables> + <genPackages prefix="Interface" disposableProviderFactory="true" ecorePackage="interface.ecore#/"> + <genClasses image="false" ecoreClass="interface.ecore#//IInterface"> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute interface.ecore#//IInterface/test"/> + </genClasses> + </genPackages> +</genmodel:GenModel> diff --git a/plugins/org.eclipse.emf.cdo.tests/model/interface_/IInterface.java b/plugins/org.eclipse.emf.cdo.tests/model/interface_/IInterface.java new file mode 100644 index 0000000000..ab1e2d8272 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/interface_/IInterface.java @@ -0,0 +1,53 @@ +/** + * <copyright> + * </copyright> + * + * $Id: IInterface.java,v 1.1 2008-07-02 14:09:49 estepper Exp $ + */ +package interface_; + +import org.eclipse.emf.cdo.CDOObject; + +/** + * <!-- begin-user-doc --> A representation of the model object '<em><b>IInterface</b></em>'. <!-- end-user-doc --> + * <p> + * The following features are supported: + * <ul> + * <li>{@link interface_.IInterface#getTest <em>Test</em>}</li> + * </ul> + * </p> + * + * @see interface_.InterfacePackage#getIInterface() + * @model interface="true" abstract="true" + * @extends CDOObject + * @generated + */ +public interface IInterface extends CDOObject +{ + /** + * Returns the value of the '<em><b>Test</b></em>' attribute. <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Test</em>' attribute isn't clear, there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * + * @return the value of the '<em>Test</em>' attribute. + * @see #setTest(String) + * @see interface_.InterfacePackage#getIInterface_Test() + * @model + * @generated + */ + String getTest(); + + /** + * Sets the value of the '{@link interface_.IInterface#getTest <em>Test</em>}' attribute. <!-- begin-user-doc --> <!-- + * end-user-doc --> + * + * @param value + * the new value of the '<em>Test</em>' attribute. + * @see #getTest() + * @generated + */ + void setTest(String value); + +} // IInterface diff --git a/plugins/org.eclipse.emf.cdo.tests/model/interface_/InterfaceFactory.java b/plugins/org.eclipse.emf.cdo.tests/model/interface_/InterfaceFactory.java new file mode 100644 index 0000000000..dc2ced40bb --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/interface_/InterfaceFactory.java @@ -0,0 +1,35 @@ +/** + * <copyright> + * </copyright> + * + * $Id: InterfaceFactory.java,v 1.1 2008-07-02 14:09:49 estepper Exp $ + */ +package interface_; + +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 interface_.InterfacePackage + * @generated + */ +public interface InterfaceFactory extends EFactory +{ + /** + * The singleton instance of the factory. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + InterfaceFactory eINSTANCE = interface_.impl.InterfaceFactoryImpl.init(); + + /** + * Returns the package supported by this factory. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @return the package supported by this factory. + * @generated + */ + InterfacePackage getInterfacePackage(); + +} // InterfaceFactory diff --git a/plugins/org.eclipse.emf.cdo.tests/model/interface_/InterfacePackage.java b/plugins/org.eclipse.emf.cdo.tests/model/interface_/InterfacePackage.java new file mode 100644 index 0000000000..5cbb559b7f --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/interface_/InterfacePackage.java @@ -0,0 +1,146 @@ +/** + * <copyright> + * </copyright> + * + * $Id: InterfacePackage.java,v 1.1 2008-07-02 14:09:49 estepper Exp $ + */ +package interface_; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; + +/** + * <!-- 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 enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * + * @see interface_.InterfaceFactory + * @model kind="package" + * @generated + */ +public interface InterfacePackage extends EPackage +{ + /** + * The package name. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + String eNAME = "interface"; + + /** + * The package namespace URI. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + String eNS_URI = "uuid://interface"; + + /** + * The package namespace name. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + String eNS_PREFIX = "interface"; + + /** + * The singleton instance of the package. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + InterfacePackage eINSTANCE = interface_.impl.InterfacePackageImpl.init(); + + /** + * The meta object id for the '{@link interface_.IInterface <em>IInterface</em>}' class. <!-- begin-user-doc --> <!-- + * end-user-doc --> + * + * @see interface_.IInterface + * @see interface_.impl.InterfacePackageImpl#getIInterface() + * @generated + */ + int IINTERFACE = 0; + + /** + * The feature id for the '<em><b>Test</b></em>' attribute. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + * @ordered + */ + int IINTERFACE__TEST = 0; + + /** + * The number of structural features of the '<em>IInterface</em>' class. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + * @ordered + */ + int IINTERFACE_FEATURE_COUNT = 1; + + /** + * Returns the meta object for class '{@link interface_.IInterface <em>IInterface</em>}'. <!-- begin-user-doc --> <!-- + * end-user-doc --> + * + * @return the meta object for class '<em>IInterface</em>'. + * @see interface_.IInterface + * @generated + */ + EClass getIInterface(); + + /** + * Returns the meta object for the attribute '{@link interface_.IInterface#getTest <em>Test</em>}'. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * + * @return the meta object for the attribute '<em>Test</em>'. + * @see interface_.IInterface#getTest() + * @see #getIInterface() + * @generated + */ + EAttribute getIInterface_Test(); + + /** + * 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 + */ + InterfaceFactory getInterfaceFactory(); + + /** + * <!-- 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 enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * + * @generated + */ + interface Literals + { + /** + * The meta object literal for the '{@link interface_.IInterface <em>IInterface</em>}' class. <!-- begin-user-doc + * --> <!-- end-user-doc --> + * + * @see interface_.IInterface + * @see interface_.impl.InterfacePackageImpl#getIInterface() + * @generated + */ + EClass IINTERFACE = eINSTANCE.getIInterface(); + + /** + * The meta object literal for the '<em><b>Test</b></em>' attribute feature. <!-- begin-user-doc --> <!-- + * end-user-doc --> + * + * @generated + */ + EAttribute IINTERFACE__TEST = eINSTANCE.getIInterface_Test(); + + } + +} // InterfacePackage diff --git a/plugins/org.eclipse.emf.cdo.tests/model/interface_/impl/InterfaceFactoryImpl.java b/plugins/org.eclipse.emf.cdo.tests/model/interface_/impl/InterfaceFactoryImpl.java new file mode 100644 index 0000000000..df202347ce --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/interface_/impl/InterfaceFactoryImpl.java @@ -0,0 +1,95 @@ +/** + * <copyright> + * </copyright> + * + * $Id: InterfaceFactoryImpl.java,v 1.1 2008-07-02 14:09:49 estepper Exp $ + */ +package interface_.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 interface_.InterfaceFactory; +import interface_.InterfacePackage; + +/** + * <!-- begin-user-doc --> An implementation of the model <b>Factory</b>. <!-- end-user-doc --> + * + * @generated + */ +public class InterfaceFactoryImpl extends EFactoryImpl implements InterfaceFactory +{ + /** + * Creates the default factory implementation. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public static InterfaceFactory init() + { + try + { + InterfaceFactory theInterfaceFactory = (InterfaceFactory)EPackage.Registry.INSTANCE + .getEFactory("uuid://interface"); + if (theInterfaceFactory != null) + { + return theInterfaceFactory; + } + } + catch (Exception exception) + { + EcorePlugin.INSTANCE.log(exception); + } + return new InterfaceFactoryImpl(); + } + + /** + * Creates an instance of the factory. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public InterfaceFactoryImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + @Override + public EObject create(EClass eClass) + { + switch (eClass.getClassifierID()) + { + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public InterfacePackage getInterfacePackage() + { + return (InterfacePackage)getEPackage(); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @deprecated + * @generated + */ + @Deprecated + public static InterfacePackage getPackage() + { + return InterfacePackage.eINSTANCE; + } + +} // InterfaceFactoryImpl diff --git a/plugins/org.eclipse.emf.cdo.tests/model/interface_/impl/InterfacePackageImpl.java b/plugins/org.eclipse.emf.cdo.tests/model/interface_/impl/InterfacePackageImpl.java new file mode 100644 index 0000000000..286f8cc4fd --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/interface_/impl/InterfacePackageImpl.java @@ -0,0 +1,189 @@ +/** + * <copyright> + * </copyright> + * + * $Id: InterfacePackageImpl.java,v 1.1 2008-07-02 14:09:49 estepper Exp $ + */ +package interface_.impl; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.impl.EPackageImpl; + +import interface_.IInterface; +import interface_.InterfaceFactory; +import interface_.InterfacePackage; + +/** + * <!-- begin-user-doc --> An implementation of the model <b>Package</b>. <!-- end-user-doc --> + * + * @generated + */ +public class InterfacePackageImpl extends EPackageImpl implements InterfacePackage +{ + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + private EClass iInterfaceEClass = 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 interface_.InterfacePackage#eNS_URI + * @see #init() + * @generated + */ + private InterfacePackageImpl() + { + super(eNS_URI, InterfaceFactory.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. + * Simple dependencies are satisfied by calling this method on all dependent packages before doing anything else. This + * method drives initialization for interdependent packages directly, in parallel with this package, itself. + * <p> + * Of this package and its interdependencies, all packages which have not yet been registered by their URI values are + * first created and registered. The packages are then initialized in two steps: meta-model objects for all of the + * packages are created before any are initialized, since one package's meta-model objects may refer to those of + * another. + * <p> + * Invocation of this method will not affect any packages that have already been initialized. <!-- begin-user-doc --> + * <!-- end-user-doc --> + * + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static InterfacePackage init() + { + if (isInited) return (InterfacePackage)EPackage.Registry.INSTANCE.getEPackage(InterfacePackage.eNS_URI); + + // Obtain or create and register package + InterfacePackageImpl theInterfacePackage = (InterfacePackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof InterfacePackageImpl ? EPackage.Registry.INSTANCE + .getEPackage(eNS_URI) + : new InterfacePackageImpl()); + + isInited = true; + + // Create package meta-data objects + theInterfacePackage.createPackageContents(); + + // Initialize created meta-data + theInterfacePackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theInterfacePackage.freeze(); + + return theInterfacePackage; + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public EClass getIInterface() + { + return iInterfaceEClass; + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public EAttribute getIInterface_Test() + { + return (EAttribute)iInterfaceEClass.getEStructuralFeatures().get(0); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public InterfaceFactory getInterfaceFactory() + { + return (InterfaceFactory)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 + iInterfaceEClass = createEClass(IINTERFACE); + createEAttribute(iInterfaceEClass, IINTERFACE__TEST); + } + + /** + * <!-- 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 + + // Initialize classes and features; add operations and parameters + initEClass(iInterfaceEClass, IInterface.class, "IInterface", IS_ABSTRACT, IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getIInterface_Test(), ecorePackage.getEString(), "test", null, 0, 1, IInterface.class, + !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + // Create resource + createResource(eNS_URI); + } + +} // InterfacePackageImpl diff --git a/plugins/org.eclipse.emf.cdo.tests/model/interface_/util/InterfaceAdapterFactory.java b/plugins/org.eclipse.emf.cdo.tests/model/interface_/util/InterfaceAdapterFactory.java new file mode 100644 index 0000000000..4f955992bd --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/interface_/util/InterfaceAdapterFactory.java @@ -0,0 +1,128 @@ +/** + * <copyright> + * </copyright> + * + * $Id: InterfaceAdapterFactory.java,v 1.1 2008-07-02 14:09:48 estepper Exp $ + */ +package interface_.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 interface_.IInterface; +import interface_.InterfacePackage; + +/** + * <!-- 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 interface_.InterfacePackage + * @generated + */ +public class InterfaceAdapterFactory extends AdapterFactoryImpl +{ + /** + * The cached model package. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + protected static InterfacePackage modelPackage; + + /** + * Creates an instance of the adapter factory. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public InterfaceAdapterFactory() + { + if (modelPackage == null) + { + modelPackage = InterfacePackage.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 InterfaceSwitch<Adapter> modelSwitch = new InterfaceSwitch<Adapter>() + { + @Override + public Adapter caseIInterface(IInterface object) + { + return createIInterfaceAdapter(); + } + + @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 interface_.IInterface <em>IInterface</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 interface_.IInterface + * @generated + */ + public Adapter createIInterfaceAdapter() + { + 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; + } + +} // InterfaceAdapterFactory diff --git a/plugins/org.eclipse.emf.cdo.tests/model/interface_/util/InterfaceSwitch.java b/plugins/org.eclipse.emf.cdo.tests/model/interface_/util/InterfaceSwitch.java new file mode 100644 index 0000000000..9979ed8ef0 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/interface_/util/InterfaceSwitch.java @@ -0,0 +1,134 @@ +/** + * <copyright> + * </copyright> + * + * $Id: InterfaceSwitch.java,v 1.1 2008-07-02 14:09:48 estepper Exp $ + */ +package interface_.util; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; + +import interface_.IInterface; +import interface_.InterfacePackage; + +import java.util.List; + +/** + * <!-- 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 interface_.InterfacePackage + * @generated + */ +public class InterfaceSwitch<T> +{ + /** + * The cached model package <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + protected static InterfacePackage modelPackage; + + /** + * Creates an instance of the switch. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public InterfaceSwitch() + { + if (modelPackage == null) + { + modelPackage = InterfacePackage.eINSTANCE; + } + } + + /** + * 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 + */ + public T doSwitch(EObject theEObject) + { + return doSwitch(theEObject.eClass(), theEObject); + } + + /** + * 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 + */ + protected T doSwitch(EClass theEClass, EObject theEObject) + { + if (theEClass.eContainer() == modelPackage) + { + return doSwitch(theEClass.getClassifierID(), theEObject); + } + else + { + List<EClass> eSuperTypes = theEClass.getESuperTypes(); + return eSuperTypes.isEmpty() ? defaultCase(theEObject) : doSwitch(eSuperTypes.get(0), theEObject); + } + } + + /** + * 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 + */ + protected T doSwitch(int classifierID, EObject theEObject) + { + switch (classifierID) + { + case InterfacePackage.IINTERFACE: + { + IInterface iInterface = (IInterface)theEObject; + T result = caseIInterface(iInterface); + if (result == null) result = defaultCase(theEObject); + return result; + } + default: + return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpreting the object as an instance of '<em>IInterface</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>IInterface</em>'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseIInterface(IInterface 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 + */ + public T defaultCase(EObject object) + { + return null; + } + +} // InterfaceSwitch diff --git a/plugins/org.eclipse.emf.cdo.tests/model/reference.ecore b/plugins/org.eclipse.emf.cdo.tests/model/reference.ecore new file mode 100644 index 0000000000..8271f31d53 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/reference.ecore @@ -0,0 +1,9 @@ +<?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="reference" + nsURI="uuid://reference" nsPrefix="reference"> + <eClassifiers xsi:type="ecore:EClass" name="Reference"> + <eStructuralFeatures xsi:type="ecore:EReference" name="ref" eType="ecore:EClass interface.ecore#//IInterface"/> + </eClassifiers> +</ecore:EPackage> diff --git a/plugins/org.eclipse.emf.cdo.tests/model/reference.genmodel b/plugins/org.eclipse.emf.cdo.tests/model/reference.genmodel new file mode 100644 index 0000000000..f469cb70c4 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/reference.genmodel @@ -0,0 +1,17 @@ +<?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" modelDirectory="/org.eclipse.emf.cdo.tests/model" + editDirectory="" editorDirectory="" modelPluginID="org.eclipse.emf.cdo.tests" + modelName="Reference" updateClasspath="false" rootExtendsInterface="org.eclipse.emf.cdo.CDOObject" + rootExtendsClass="org.eclipse.emf.internal.cdo.CDOObjectImpl" reflectiveDelegation="true" + codeFormatting="true" testsDirectory="" importerID="org.eclipse.emf.importer.cdo" + featureDelegation="Reflective" complianceLevel="5.0" copyrightFields="false" usedGenPackages="interface.genmodel#//interface"> + <foreignModel>reference.ecore</foreignModel> + <modelPluginVariables>CDO=org.eclipse.emf.cdo</modelPluginVariables> + <genPackages prefix="Reference" disposableProviderFactory="true" ecorePackage="reference.ecore#/"> + <genClasses ecoreClass="reference.ecore#//Reference"> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference reference.ecore#//Reference/ref"/> + </genClasses> + </genPackages> +</genmodel:GenModel> diff --git a/plugins/org.eclipse.emf.cdo.tests/model/reference/Reference.java b/plugins/org.eclipse.emf.cdo.tests/model/reference/Reference.java new file mode 100644 index 0000000000..93c860acfa --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/reference/Reference.java @@ -0,0 +1,55 @@ +/** + * <copyright> + * </copyright> + * + * $Id: Reference.java,v 1.1 2008-07-02 14:09:49 estepper Exp $ + */ +package reference; + +import org.eclipse.emf.cdo.CDOObject; + +import interface_.IInterface; + +/** + * <!-- begin-user-doc --> A representation of the model object '<em><b>Reference</b></em>'. <!-- end-user-doc --> + * <p> + * The following features are supported: + * <ul> + * <li>{@link reference.Reference#getRef <em>Ref</em>}</li> + * </ul> + * </p> + * + * @see reference.ReferencePackage#getReference() + * @model + * @extends CDOObject + * @generated + */ +public interface Reference extends CDOObject +{ + /** + * Returns the value of the '<em><b>Ref</b></em>' reference. <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Ref</em>' reference isn't clear, there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * + * @return the value of the '<em>Ref</em>' reference. + * @see #setRef(IInterface) + * @see reference.ReferencePackage#getReference_Ref() + * @model + * @generated + */ + IInterface getRef(); + + /** + * Sets the value of the '{@link reference.Reference#getRef <em>Ref</em>}' reference. <!-- begin-user-doc --> <!-- + * end-user-doc --> + * + * @param value + * the new value of the '<em>Ref</em>' reference. + * @see #getRef() + * @generated + */ + void setRef(IInterface value); + +} // Reference diff --git a/plugins/org.eclipse.emf.cdo.tests/model/reference/ReferenceFactory.java b/plugins/org.eclipse.emf.cdo.tests/model/reference/ReferenceFactory.java new file mode 100644 index 0000000000..0f6d7e9b97 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/reference/ReferenceFactory.java @@ -0,0 +1,43 @@ +/** + * <copyright> + * </copyright> + * + * $Id: ReferenceFactory.java,v 1.1 2008-07-02 14:09:49 estepper Exp $ + */ +package reference; + +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 reference.ReferencePackage + * @generated + */ +public interface ReferenceFactory extends EFactory +{ + /** + * The singleton instance of the factory. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + ReferenceFactory eINSTANCE = reference.impl.ReferenceFactoryImpl.init(); + + /** + * Returns a new object of class '<em>Reference</em>'. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @return a new object of class '<em>Reference</em>'. + * @generated + */ + Reference createReference(); + + /** + * Returns the package supported by this factory. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @return the package supported by this factory. + * @generated + */ + ReferencePackage getReferencePackage(); + +} // ReferenceFactory diff --git a/plugins/org.eclipse.emf.cdo.tests/model/reference/ReferencePackage.java b/plugins/org.eclipse.emf.cdo.tests/model/reference/ReferencePackage.java new file mode 100644 index 0000000000..0cd7be246a --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/reference/ReferencePackage.java @@ -0,0 +1,146 @@ +/** + * <copyright> + * </copyright> + * + * $Id: ReferencePackage.java,v 1.1 2008-07-02 14:09:49 estepper Exp $ + */ +package reference; + +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 enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * + * @see reference.ReferenceFactory + * @model kind="package" + * @generated + */ +public interface ReferencePackage extends EPackage +{ + /** + * The package name. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + String eNAME = "reference"; + + /** + * The package namespace URI. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + String eNS_URI = "uuid://reference"; + + /** + * The package namespace name. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + String eNS_PREFIX = "reference"; + + /** + * The singleton instance of the package. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + ReferencePackage eINSTANCE = reference.impl.ReferencePackageImpl.init(); + + /** + * The meta object id for the '{@link reference.impl.ReferenceImpl <em>Reference</em>}' class. <!-- begin-user-doc --> + * <!-- end-user-doc --> + * + * @see reference.impl.ReferenceImpl + * @see reference.impl.ReferencePackageImpl#getReference() + * @generated + */ + int REFERENCE = 0; + + /** + * The feature id for the '<em><b>Ref</b></em>' reference. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + * @ordered + */ + int REFERENCE__REF = 0; + + /** + * The number of structural features of the '<em>Reference</em>' class. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + * @ordered + */ + int REFERENCE_FEATURE_COUNT = 1; + + /** + * Returns the meta object for class '{@link reference.Reference <em>Reference</em>}'. <!-- begin-user-doc --> <!-- + * end-user-doc --> + * + * @return the meta object for class '<em>Reference</em>'. + * @see reference.Reference + * @generated + */ + EClass getReference(); + + /** + * Returns the meta object for the reference '{@link reference.Reference#getRef <em>Ref</em>}'. <!-- begin-user-doc + * --> <!-- end-user-doc --> + * + * @return the meta object for the reference '<em>Ref</em>'. + * @see reference.Reference#getRef() + * @see #getReference() + * @generated + */ + EReference getReference_Ref(); + + /** + * 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 + */ + ReferenceFactory getReferenceFactory(); + + /** + * <!-- 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 enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * + * @generated + */ + interface Literals + { + /** + * The meta object literal for the '{@link reference.impl.ReferenceImpl <em>Reference</em>}' class. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * + * @see reference.impl.ReferenceImpl + * @see reference.impl.ReferencePackageImpl#getReference() + * @generated + */ + EClass REFERENCE = eINSTANCE.getReference(); + + /** + * The meta object literal for the '<em><b>Ref</b></em>' reference feature. <!-- begin-user-doc --> <!-- + * end-user-doc --> + * + * @generated + */ + EReference REFERENCE__REF = eINSTANCE.getReference_Ref(); + + } + +} // ReferencePackage diff --git a/plugins/org.eclipse.emf.cdo.tests/model/reference/impl/ReferenceFactoryImpl.java b/plugins/org.eclipse.emf.cdo.tests/model/reference/impl/ReferenceFactoryImpl.java new file mode 100644 index 0000000000..f93979e1c2 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/reference/impl/ReferenceFactoryImpl.java @@ -0,0 +1,109 @@ +/** + * <copyright> + * </copyright> + * + * $Id: ReferenceFactoryImpl.java,v 1.1 2008-07-02 14:09:49 estepper Exp $ + */ +package reference.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 reference.Reference; +import reference.ReferenceFactory; +import reference.ReferencePackage; + +/** + * <!-- begin-user-doc --> An implementation of the model <b>Factory</b>. <!-- end-user-doc --> + * + * @generated + */ +public class ReferenceFactoryImpl extends EFactoryImpl implements ReferenceFactory +{ + /** + * Creates the default factory implementation. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public static ReferenceFactory init() + { + try + { + ReferenceFactory theReferenceFactory = (ReferenceFactory)EPackage.Registry.INSTANCE + .getEFactory("uuid://reference"); + if (theReferenceFactory != null) + { + return theReferenceFactory; + } + } + catch (Exception exception) + { + EcorePlugin.INSTANCE.log(exception); + } + return new ReferenceFactoryImpl(); + } + + /** + * Creates an instance of the factory. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public ReferenceFactoryImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + @Override + public EObject create(EClass eClass) + { + switch (eClass.getClassifierID()) + { + case ReferencePackage.REFERENCE: + return (EObject)createReference(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public Reference createReference() + { + ReferenceImpl reference = new ReferenceImpl(); + return reference; + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public ReferencePackage getReferencePackage() + { + return (ReferencePackage)getEPackage(); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @deprecated + * @generated + */ + @Deprecated + public static ReferencePackage getPackage() + { + return ReferencePackage.eINSTANCE; + } + +} // ReferenceFactoryImpl diff --git a/plugins/org.eclipse.emf.cdo.tests/model/reference/impl/ReferenceImpl.java b/plugins/org.eclipse.emf.cdo.tests/model/reference/impl/ReferenceImpl.java new file mode 100644 index 0000000000..2a0c1dc998 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/reference/impl/ReferenceImpl.java @@ -0,0 +1,82 @@ +/** + * <copyright> + * </copyright> + * + * $Id: ReferenceImpl.java,v 1.1 2008-07-02 14:09:49 estepper Exp $ + */ +package reference.impl; + +import org.eclipse.emf.internal.cdo.CDOObjectImpl; + +import org.eclipse.emf.ecore.EClass; + +import reference.Reference; +import reference.ReferencePackage; +import interface_.IInterface; + +/** + * <!-- begin-user-doc --> An implementation of the model object '<em><b>Reference</b></em>'. <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link reference.impl.ReferenceImpl#getRef <em>Ref</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class ReferenceImpl extends CDOObjectImpl implements Reference +{ + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + protected ReferenceImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + @Override + protected EClass eStaticClass() + { + return ReferencePackage.Literals.REFERENCE; + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + @Override + protected int eStaticFeatureCount() + { + return 0; + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public IInterface getRef() + { + return (IInterface)eGet(ReferencePackage.Literals.REFERENCE__REF, true); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public void setRef(IInterface newRef) + { + eSet(ReferencePackage.Literals.REFERENCE__REF, newRef); + } + +} // ReferenceImpl diff --git a/plugins/org.eclipse.emf.cdo.tests/model/reference/impl/ReferencePackageImpl.java b/plugins/org.eclipse.emf.cdo.tests/model/reference/impl/ReferencePackageImpl.java new file mode 100644 index 0000000000..8f5e50b692 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/reference/impl/ReferencePackageImpl.java @@ -0,0 +1,198 @@ +/** + * <copyright> + * </copyright> + * + * $Id: ReferencePackageImpl.java,v 1.1 2008-07-02 14:09:49 estepper Exp $ + */ +package reference.impl; + +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 reference.Reference; +import reference.ReferenceFactory; +import reference.ReferencePackage; +import interface_.InterfacePackage; + +/** + * <!-- begin-user-doc --> An implementation of the model <b>Package</b>. <!-- end-user-doc --> + * + * @generated + */ +public class ReferencePackageImpl extends EPackageImpl implements ReferencePackage +{ + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + private EClass referenceEClass = 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 reference.ReferencePackage#eNS_URI + * @see #init() + * @generated + */ + private ReferencePackageImpl() + { + super(eNS_URI, ReferenceFactory.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. + * Simple dependencies are satisfied by calling this method on all dependent packages before doing anything else. This + * method drives initialization for interdependent packages directly, in parallel with this package, itself. + * <p> + * Of this package and its interdependencies, all packages which have not yet been registered by their URI values are + * first created and registered. The packages are then initialized in two steps: meta-model objects for all of the + * packages are created before any are initialized, since one package's meta-model objects may refer to those of + * another. + * <p> + * Invocation of this method will not affect any packages that have already been initialized. <!-- begin-user-doc --> + * <!-- end-user-doc --> + * + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static ReferencePackage init() + { + if (isInited) return (ReferencePackage)EPackage.Registry.INSTANCE.getEPackage(ReferencePackage.eNS_URI); + + // Obtain or create and register package + ReferencePackageImpl theReferencePackage = (ReferencePackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof ReferencePackageImpl ? EPackage.Registry.INSTANCE + .getEPackage(eNS_URI) + : new ReferencePackageImpl()); + + isInited = true; + + // Initialize simple dependencies + InterfacePackage.eINSTANCE.eClass(); + + // Create package meta-data objects + theReferencePackage.createPackageContents(); + + // Initialize created meta-data + theReferencePackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theReferencePackage.freeze(); + + return theReferencePackage; + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public EClass getReference() + { + return referenceEClass; + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public EReference getReference_Ref() + { + return (EReference)referenceEClass.getEStructuralFeatures().get(0); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public ReferenceFactory getReferenceFactory() + { + return (ReferenceFactory)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 + referenceEClass = createEClass(REFERENCE); + createEReference(referenceEClass, REFERENCE__REF); + } + + /** + * <!-- 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); + + // Obtain other dependent packages + InterfacePackage theInterfacePackage = (InterfacePackage)EPackage.Registry.INSTANCE + .getEPackage(InterfacePackage.eNS_URI); + + // Create type parameters + + // Set bounds for type parameters + + // Add supertypes to classes + + // Initialize classes and features; add operations and parameters + initEClass(referenceEClass, Reference.class, "Reference", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getReference_Ref(), theInterfacePackage.getIInterface(), null, "ref", null, 0, 1, Reference.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); + } + +} // ReferencePackageImpl diff --git a/plugins/org.eclipse.emf.cdo.tests/model/reference/util/ReferenceAdapterFactory.java b/plugins/org.eclipse.emf.cdo.tests/model/reference/util/ReferenceAdapterFactory.java new file mode 100644 index 0000000000..25d51a5bd2 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/reference/util/ReferenceAdapterFactory.java @@ -0,0 +1,128 @@ +/** + * <copyright> + * </copyright> + * + * $Id: ReferenceAdapterFactory.java,v 1.1 2008-07-02 14:09:48 estepper Exp $ + */ +package reference.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 reference.Reference; +import reference.ReferencePackage; + +/** + * <!-- 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 reference.ReferencePackage + * @generated + */ +public class ReferenceAdapterFactory extends AdapterFactoryImpl +{ + /** + * The cached model package. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + protected static ReferencePackage modelPackage; + + /** + * Creates an instance of the adapter factory. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public ReferenceAdapterFactory() + { + if (modelPackage == null) + { + modelPackage = ReferencePackage.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 ReferenceSwitch<Adapter> modelSwitch = new ReferenceSwitch<Adapter>() + { + @Override + public Adapter caseReference(Reference object) + { + return createReferenceAdapter(); + } + + @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 reference.Reference <em>Reference</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 reference.Reference + * @generated + */ + public Adapter createReferenceAdapter() + { + 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; + } + +} // ReferenceAdapterFactory diff --git a/plugins/org.eclipse.emf.cdo.tests/model/reference/util/ReferenceSwitch.java b/plugins/org.eclipse.emf.cdo.tests/model/reference/util/ReferenceSwitch.java new file mode 100644 index 0000000000..9419c20dea --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/model/reference/util/ReferenceSwitch.java @@ -0,0 +1,134 @@ +/** + * <copyright> + * </copyright> + * + * $Id: ReferenceSwitch.java,v 1.1 2008-07-02 14:09:48 estepper Exp $ + */ +package reference.util; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; + +import reference.Reference; +import reference.ReferencePackage; + +import java.util.List; + +/** + * <!-- 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 reference.ReferencePackage + * @generated + */ +public class ReferenceSwitch<T> +{ + /** + * The cached model package <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + protected static ReferencePackage modelPackage; + + /** + * Creates an instance of the switch. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public ReferenceSwitch() + { + if (modelPackage == null) + { + modelPackage = ReferencePackage.eINSTANCE; + } + } + + /** + * 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 + */ + public T doSwitch(EObject theEObject) + { + return doSwitch(theEObject.eClass(), theEObject); + } + + /** + * 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 + */ + protected T doSwitch(EClass theEClass, EObject theEObject) + { + if (theEClass.eContainer() == modelPackage) + { + return doSwitch(theEClass.getClassifierID(), theEObject); + } + else + { + List<EClass> eSuperTypes = theEClass.getESuperTypes(); + return eSuperTypes.isEmpty() ? defaultCase(theEObject) : doSwitch(eSuperTypes.get(0), theEObject); + } + } + + /** + * 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 + */ + protected T doSwitch(int classifierID, EObject theEObject) + { + switch (classifierID) + { + case ReferencePackage.REFERENCE: + { + Reference reference = (Reference)theEObject; + T result = caseReference(reference); + if (result == null) result = defaultCase(theEObject); + return result; + } + default: + return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpreting the object as an instance of '<em>Reference</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>Reference</em>'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseReference(Reference 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 + */ + public T defaultCase(EObject object) + { + return null; + } + +} // ReferenceSwitch diff --git a/plugins/org.eclipse.emf.cdo.tests/plugin.xml b/plugins/org.eclipse.emf.cdo.tests/plugin.xml new file mode 100644 index 0000000000..2f09fbe3cd --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/plugin.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.3"?> +<!-- + <copyright> + + Copyright (c) 2004 - 2008 Eike Stepper, Germany. + 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: + Eike Stepper - Initial API and implementation + + </copyright> +--> + +<plugin> + + <extension point="org.eclipse.emf.ecore.generated_package"> + <package + uri = "http://www.fernuni-hagen.de/ST/dummy/base.ecore" + class = "base.BasePackage" + genModel = "model/base.genmodel" /> + <package + class="derived.DerivedPackage" + genModel="model/derived.genmodel" + uri="http://www.fernuni-hagen.de/ST/dummy/derived.ecore"> + </package> + <package + class="reference.ReferencePackage" + genModel="model/reference.genmodel" + uri="uuid://reference"> + </package> + <package + class="interface_.InterfacePackage" + genModel="model/interface.genmodel" + uri="uuid://interface"> + </package> + </extension> + +</plugin> diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java index 6bfaf7889e..2af35cb115 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java @@ -47,6 +47,7 @@ import org.eclipse.net4j.util.transaction.TransactionException; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; import java.text.MessageFormat; import java.util.ArrayList; @@ -401,24 +402,36 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction private List<CDOPackage> analyzeNewPackages() { - // Find all used classes and their super classes Set<EClass> usedClasses = new HashSet<EClass>(); for (CDOObject object : newObjects.values()) { - EClass usedClass = object.eClass(); - if (usedClasses.add(usedClass)) + findAllUsedEClasses(object.eClass(), usedClasses); + } + + return analyzeNewPackages(usedClasses, getSession().getPackageManager()); + } + + /** + * Find all used classes, their super classes and their referenced classes + */ + private static void findAllUsedEClasses(EClass eClass, Set<EClass> foundClasses) + { + if (foundClasses.add(eClass)) + { + for (EClass superType : eClass.getEAllSuperTypes()) { - for (EClass superType : usedClass.getEAllSuperTypes()) - { - usedClasses.add(superType); - } + findAllUsedEClasses(superType, foundClasses); } - } - return analyzeNewPackages(usedClasses); + for (EReference eReference : eClass.getEAllReferences()) + { + findAllUsedEClasses(eReference.getEReferenceType(), foundClasses); + } + } } - private List<CDOPackage> analyzeNewPackages(Collection<EClass> eClasses) + private static List<CDOPackage> analyzeNewPackages(Collection<EClass> eClasses, + CDOSessionPackageManagerImpl packageManager) { // Calculate the top level packages of the used classes Set<EPackage> usedPackages = new HashSet<EPackage>(); @@ -429,7 +442,6 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction } // Determine which of the used packages are new - CDOSessionPackageManagerImpl packageManager = getSession().getPackageManager(); List<CDOPackage> newPackages = new ArrayList<CDOPackage>(); for (EPackage usedPackage : usedPackages) { |