@Primary

Target: Primary annotation.

Description: Marks an annotation as a primary. A primary annotation must be the only one of it's type to annotate an element and excludes all the other primary annotations.

Primary annotations can have one of two types: pure primary and non-pure primary.
Non-pure primary annotations might be used as non-primary annotations on some contexts.
To define these contexts the programmer must supply a list of annotations to whom the annotation yields its primariness.

JavaDoc: Click here

Attributes:

Name Description Data type Required Default value
yieldTo The list of the FQNs of the annotations that force the primariness yielding. String No None

Examples:

/* Pure primary annotation. */
@Primary
public @interface MyAnnotation {
    ...
}

/* Non-pure primary annotation. */
@Primary(yieldTo = "my.package.MyOtherAnnotation")
public @interface MyAnnotation {
    ...
}

Back to meta-annotation reference