I have is an interface which is meant only to be overridden by enums -
interface Parent{
int someMethod();
}
and method in which I am going to pass an implementor of Parent. this method wants to restrict users to pass any other implementor other than enum -
public static <T extends Enum<? extends Parent>> T fromInt(Class<T> enumClass){}
Now the issue is
- the enum signature is unclean plus using
?. In order to access
someMethodof parent class will need to be type casted in the method. If we like to access it like this -Arrays.stream(enumClass.getEnumConstants()) .filter(ev -> ((Parent)ev).someMethod() == someVal) .findFirst().get();
Is there a better way of creating signature of this method to solve these issues?