I'm trying to create an annotation which can accept multiple classes as input. Typical usage would be
@Prerequisites{FirstPrerequisite.class, SecondPrerequisite.class}
For this I can create an annotation as shown below
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Inherited
public @interface Prerequisites {
public Class<?>[] value();
}
I want to restrict the types that are allowed in the prerequisites annotation. If I give something like public Class<? extends Dependency>[] value();
It is working however, the problem is My FirstPrerequisite and SecondsPrerequisite may bot be extended from same type. I tried the following but none seemed to work, they are giving compilation errors.
public Class<? extends Dependency & TestCaseStep>[] value();
public Class<? extends Dependency , TestCaseStep>[] value();
public Class<T extends Dependency & TestCaseStep>[] value();
How to bound Generics to take inputs of two different types?