Reputation: 2874
If I have annotation like this:
public @interface MyAnnotaton{
String className():
Class clazz();
}
what i should do to limit setting element className if element clazz is set?
Upvotes: 2
Views: 309
Reputation: 236170
Provide a default value for one of the elements, and in your AnnotationProcessor code the necessary logic to detect which element should be processed
public @interface MyAnnotation {
Class clazz();
String className() default "<none>";
}
Upvotes: 4
Reputation: 39990
I'd wager to say this is impossible – annotations aren't executable code and do not intrinsically have any logic. Either settle on one of the two, or pick which one takes precedence and document the annotation accordingly.
Upvotes: 1