I'm late, but either way, since intdef introduces the annotation, you can create the annotation using a custom class and then use it in the same way. given the fact that annotations are needed by primitives, you need to pass the interface as a type of annotation class and use subclasses as an array of values.
Example:
public interface GenericContainer<T, X> { public T getValueOne(); public X getValueTwo(); }
then the implementation for true / 1
public class TrueContainer implements GenericContainer<Boolean, Integer> { @Override public Boolean getValueOne() { return true; } @Override public Integer getValueTwo() { return 1; } }
and others for false / 0
public class FalseContainer implements GenericContainer<Boolean, Integer> { @Override public Boolean getValueOne() { return false; } @Override public Integer getValueTwo() { return 0; } }
finally use them:
@Retention(RetentionPolicy.SOURCE) @GenericDef({TrueContainer.class, FalseContainer.class}) public @interface genericTest{} boolean test = isTest(new FalseContainer());
source share