I need get name from Enum with reflection of java.
I know I can that for class: (but I could not find it about Enums)
public class EnumWrapper<T> {
@SuppressWarnings("unchecked")
public String getType() {
Type type = getClass().getGenericSuperclass();
ParameterizedType pt = (ParameterizedType) type;
Class<T> entity = (Class<T>) pt.getActualTypeArguments()[0];
String name = t.getClass().getName();
return name;
}
}
I maybe set any of the Enums :
public enum Gender {
WOMAN, MAN, OTHER
}
public enum Language {
Norwegian, ENGLISH, PERSIAN
}
Aucun commentaire:
Enregistrer un commentaire