October 21st, 2013
3:55 pm
You can translate a string Enum into its corresponding Enum using the Enum in this way :-
//Assuming Fields is the target Enum
String fieldName = “myField”;
Fields field = Fields.valueOf(fieldName);
However this can also be done if you are given a class object of the Enum:-
//Assuming fieldClass is a class object for the Fields Enum
String fieldName = “myField”;
Fields field = Enum.valueOf(fieldClass, fieldName);