Yes, Enum.valueOf() will work fine.
Blah.valueOf("Q") will give you Blah.Q.
Here’s the method you can use to find the enum value of a string:
/**
* A general method for all enums since they can't have another base class
* @param <T> Enum type
* @param c enum type. All enums must be all caps.
* @param string case insensitive
* @return corresponding enum, or null
*/
public static <T extends Enum<T>> T getEnumFromString(Class<T> c, String string) {
if( c != null && string != null ) {
try {
return Enum.valueOf(c, string.trim().toUpperCase());
} catch(IllegalArgumentException ex) {
}
}
return null;
}
0) : "length is too short"));
If you have any doubts, mention them in the comment section below.