I have a problem, I need to resolve type of class which replaced the generic type parameter. Here is the code:
public class EnumSetPlay {
private enum SomeEnum {ONE, TWO}
private static class Test<E extends Enum> {
private Class<E> clazz = (Class<E>) GenericTypeResolver.resolveTypeArgument(getClass(), Test.class);;
public void test() {
for (E element : EnumSet.allOf(clazz))
System.out.println(element);
}
}
public static void main(String... args) {
new Test<SomeEnum>().test();
}
}
I need to get class type SomeEnum. I trying to use spring GenericTypeResolver class, but I have next error:
error: incompatible types required: E found: Object where E is a type-variable: E extends Enum declared in class Test