I have the following BeanValidation code that works fine, and permits to validate that a bean annotated with:
@EnumValue(enumClass = MyTestEnum.class)
privat
My guess is that in ? extends Enum>
the two ?
could be different whereas allOf
expects a T extends Enum
where both T
are the same.
For example, consider the following code:
static enum MyEnum {}
static class EnumValue> {
Class enumClass;
EnumValue(Class enumClass) {
this.enumClass = enumClass;
}
Class enumClass() { return enumClass; }
}
These lines will compile:
EnumValue> enumValue = new EnumValue(MyEnum.class); // raw constructor
Set extends Enum>> enumInstances = EnumSet.allOf(enumValue.enumClass());
because we know that the two T
in enumValue.enumClass()
are the same but this won't:
EnumValue enumValue = new EnumValue(MyEnum.class);
Class extends Enum>> enumSelected = enumValue.enumClass();
Set extends Enum>> enumInstances = EnumSet.allOf(enumSelected);
because you have lost information by using a Class extends Enum>>
as an intermediate step.