Suppose I have a generic type Pthat is Enum, that is <P extends Enum<P>>, and I want to get the Enum value from a string, for example:
String foo = "foo";
P fooEnum = Enum.valueOf(P.class, foo);
This will result in a compilation error because it is P.classnot valid. So what can I do to make the above code work?
source
share