Reputation: 91
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?
Upvotes: 1
Views: 318
Reputation: 115
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()
Upvotes: 0
Reputation: 1536
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
Upvotes: 3