The correct syntax is:
Enum.class.isAssignableFrom(test.MyEnum.class)
but for transfers, a more convenient method:
if (someObject.getClass().isEnum()))
Update: for enumeration elements with a body (for example, for overriding methods) this will not work. In this case, use
if (someObject instanceof Enum<?>)
Reference:
Sean Patrick Floyd Nov 12 '10 at 16:03 2010-11-12 16:03
source share