Look at this answer. Everything is good, except that:
public <E extends Enum<E> & MyInterface> E getParametrizedEnum() {
String someString = "..."
return MyEnum.valueOf(someString); //compile error here
}
Intellij idea tells me "Required E, found com.mypackage.MyEnum".
Have to be cast like that:
public <E extends Enum<E> & MyInterface> E getParametrizedEnum() {
String someString = "..."
return (E) MyEnum.valueOf(someString); //compile error here
}
Is there a way to return parameterized enum with interface without casting?