问题
How to get information about an attribute of enum type?
I have an EClass
with an attribute which is type of enum. I know you can use the following code to determine the type of an attribute
EDataType type = attr.getEAttributeType();
if (type == EcorePackage.Literals.EINT);
//do something
if (type == EcorePackage.Literals.EENUM);
// do something
But the line (type == EcorePackage.Literals.EENUM
) doesn't work, thus I am wondering how to determine an attribute is type of eEnum, given any Ecore metamodels.
回答1:
For enumerated types you could use either of:
type instanceof EEnum
type.eClass() == EcorePackage.eINSTANCE.getEEnum()
来源:https://stackoverflow.com/questions/12177465/enum-data-type-in-emf