Suppose I have a method
public <T extends Enum<T>> Enum<T> getEnumValue(String string, ??)
And another method, in a different class,
public T method(String string)
...
getEnumValue(string, ??)
What would I pass from method 2 as the argument to method 1 so that I can get the enum value, i.e. in my fantasy world I could just do:
method 2:
getEnumValue(string, T.class)
method 1:
getEnumValue(String string, Class<T> clazz)
return Enum.valueOf(clazz, string)
Aucun commentaire:
Enregistrer un commentaire