Enum data type in EMF

非 Y 不嫁゛ 提交于 2020-01-05 07:22:10

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!