How can I programmatically add an EGeneric Type Argument to an EAttribute
?
I can create an EAttribute like this:
EAttribute eAttribute = EcoreFactory.eINSTANCE.createEAttribute();
eAttribute.setName("myAttribute");
EDataType dataType = EcorePackage.eINSTANCE.getEEList();
// add here String to List as generic argument?
eAttribute.setEType(dataType);
But with that code snippet the generic type argument of the EEList
is not specified. In Eclipse I would fix that with New Child > EGeneric Type Argument
and then set the EClassifier
of the EGeneric Type Argument to EString
. But how can I do that programmatically?
It took me some time but I have a solution:
EGenericType
is created from theEcoreFactory
. That is our EGeneric Type Argument.EString
.EGenericType
of theEAttribute
(NOT theEType
we set earlier).In hindsight it makes sense that we do not modify the
EDataType
, we rather modifiy theEAttribute
.