I have a pretty simple case where I am doing a basic general purpose:
final Detail detail = field.getAnnotation(Detail.class);
final String example = detail.example();
final Class<?> type = field.getType();
if (List.class.isAssignableFrom(type))
...
else if (Enum.class.isAssignableFrom(type))
setValue(contract, field, Enum.valueOf(type, example));
else if (...)
.....
but Enum.valueOf () is a little hard to name, in my case an error:
valueOf (java.lang.Class, java.lang.String) in java.lang.Enum cannot be applied to (java.lang.Class, java.lang.String)
This makes sense, as a type Class<Object>. But as EnumCRTP is, I can't find a good way to cast type to make the compiler happy. Does the source type use a Enum.valueOf((Class)type, example))single answer? This gives me 2 warnings instead of one.
source
share