Annotation Interface AliasFor
@Retention(RUNTIME)
@Target(METHOD)
@Documented
@Repeatable(Aliases.class)
public @interface AliasFor
Allows specifying an annotation member alias. In other words, a value of an annotation member can be used to represent the value of another annotation's member or a another member within the same annotation.
The representation is constructed via the AnnotationMetadata interface
- Since:
- 1.0
- Author:
- Graeme Rocher
- See Also:
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionClass<? extends Annotation> booleanWhether the alias should also be applied using the member's default value when the member is not explicitly set.intWhen the aliasedannotation()is a repeatable annotation declared multiple times as a stereotype of the annotation this member belongs to, selects which occurrence (in declaration order, starting at zero) the alias applies to.
-
Element Details
-
member
-
annotation
Class<? extends Annotation> annotation- Returns:
- The type of annotation in which the aliased
member()is declared. If not specified the alias is applied to the current annotation.
- Default:
java.lang.annotation.Annotation.class
-
annotationName
-
index
int indexWhen the aliasedannotation()is a repeatable annotation declared multiple times as a stereotype of the annotation this member belongs to, selects which occurrence (in declaration order, starting at zero) the alias applies to. The default of-1applies the alias to every declared occurrence.- Returns:
- The occurrence index of the aliased repeatable annotation
- Since:
- 5.2
- Default:
-1
-
applyDefault
boolean applyDefaultWhether the alias should also be applied using the member's default value when the member is not explicitly set. By default, aliases only apply to explicitly set members. This allows modelling semantics such asjakarta.validation.OverridesAttribute, where the overriding member's default value replaces the value declared on the aliased annotation.- Returns:
- Whether to apply the alias for the member's default value
- Since:
- 5.2
- Default:
false
-