Reputation: 809
Let's say we have the following interfaces -
@Retention(RetentionPolicy.SOURCE)
@StringDef({EventA.EVENT})
public @interface EventA{
String EVENT= "eventA";
}
@Retention(RetentionPolicy.SOURCE)
@StringDef({EventB.EVENT})
public @interface EventB{
String EVENT= "eventB";
}
I want to declare a function in which his argument type is one of thus interfaces such as -
public void foo(Event x) { // Event should be only EventA or EventB
...
}
Is there a way I can achieve this?
Upvotes: 0
Views: 57