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 Elements
    Modifier and Type
    Optional Element
    Description
    Class<? extends Annotation>
     
     
    boolean
    Whether the alias should also be applied using the member's default value when the member is not explicitly set.
    int
    When the aliased annotation() 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

      String member
      Returns:
      The name of the member that this member is an alias for
      Default:
      ""
    • 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

      String annotationName
      Returns:
      The name of the annotation in which the aliased member() is declared. If not specified the alias is applied to the current annotation.
      Default:
      ""
    • index

      int index
      When the aliased annotation() 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 -1 applies the alias to every declared occurrence.
      Returns:
      The occurrence index of the aliased repeatable annotation
      Since:
      5.2
      Default:
      -1
    • applyDefault

      boolean applyDefault
      Whether 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 as jakarta.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