Enum data type in EMF

How to get information about an attribute of an enumeration type?

I have EClasswith an attribute that is an enum type. I know that you can use the following code to determine attribute type

EDataType type = attr.getEAttributeType();
if (type == EcorePackage.Literals.EINT);
//do something
if (type == EcorePackage.Literals.EENUM);
// do something

But line ( type == EcorePackage.Literals.EENUM) doesn't work, so I'm wondering how to define an attribute of type eEnum, given any Ecore metamodels.

+1
source share
1 answer

For the listed types, you can use any of:

type instanceof EEnum
type.eClass() == EcorePackage.eINSTANCE.getEEnum()
0
source

All Articles