1
votes

The ecore model editor does not allow adding classes as children to classes; doing so manually as in

...
<eClassifiers xsi:type="ecore:EClass" name="Test_Class">
    <eClassifiers xsi:type="ecore:EClass" name="Nested_Class"></eClassifiers>
    ...

results in

org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'eClassifiers' not found. (platform:/resource/EMFTestProject/model/My.ecore, 5, 62)

Is there any way to model something like nested classes in ecore files?

2
You mean that you wanna create a containment relation between two classes ?sali333

2 Answers

3
votes

You cannot create nested EClasses in Ecore. The only elements that can be contained by EClass are EStructuralFeatures (references and attributes), EOperation, EAnnotation, EGenericType and ETypeParameter.

Take a look to the Ecore metamodel: http://download.eclipse.org/modeling/emf/emf/javadoc/2.10.0/org/eclipse/emf/ecore/package-summary.html

0
votes

For creating a containment reference between two EClass objects in a metamodel you have to create A EReference ereference=EcoreFactory.eInstance.create and add is the the mother class : motherclass.getEReferences().add(ereference)
and put the children class as EType of the ereference. ereference.setEType()