I have defined in an XML something like :
<Property>
<value>APPLE</value>
<enum>com.mycompany.MyEnum</enum>
</Property>
I try to instantiate that enum in code. here is what I have so far
Class<?> clazz = Class.forName(pProperty.getEnum());
if (!clazz.isEnum())
throw new IllegalArgumentException(MessageFormat.format("Class %s is not an enumeration.", pProperty.getEnum()));
After that, I try to call valueOf(java.lang.String), but I got a NoSuchMethodException
MyEnum is defined like this :
package com.mycompany;
public enum MyEnum
{
APPLE, PEER, LEMON
}
Is it possible to do that ?
Thanks