Package: org.codehaus.groovy.ast

## [Java] Class AnnotationNode

- org.codehaus.groovy.ast.AnnotationNode

-     public class AnnotationNode
      extends ASTNode

  Represents an annotation which can be attached to interfaces, classes, methods, fields, parameters, and other places.

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static int` | `ANNOTATION_TARGET` |
    `static int` | `CONSTRUCTOR_TARGET` |
    `static int` | `FIELD_TARGET` |
    `static int` | `IMPORT_TARGET` | Groovy-only target for annotations on import statements.
    `static int` | `LOCAL_VARIABLE_TARGET` |
    `static int` | `METHOD_TARGET` |
    `static int` | `PACKAGE_TARGET` |
    `static int` | `PARAMETER_TARGET` |
    `static int` | `RECORD_COMPONENT_TARGET` |
    `static int` | `STATEMENT_TARGET` | Groovy-only target for statement-level annotations (e.g. on `for`/`while` loops).
    `static int` | `TYPE_PARAMETER_TARGET` |
    `static int` | `TYPE_TARGET` |
    `static int` | `TYPE_USE_TARGET` |

  - ### Constructor Summary

    Constructors
    Constructor and description
    `AnnotationNode(ClassNode type)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public void` | `addMember(String name, Expression value)`
    `` | `public ClassNode` | `getClassNode()`
    `` | `public Expression` | `getMember(String name)`
    `` | `public Map<String, Expression>` | `getMembers()`
    `` | `public String` | `getText()`
    `` | `public boolean` | `hasClassRetention()` Flag corresponding to `RetentionPolicy.CLASS`.
    `` | `public boolean` | `hasRuntimeRetention()` Flag corresponding to `RetentionPolicy.RUNTIME`.
    `` | `public boolean` | `hasSourceRetention()` Flag corresponding to `RetentionPolicy.SOURCE`.
    `` | `public boolean` | `isBuiltIn()`
    `` | `public boolean` | `isTargetAllowed(int target)`
    `` | `public void` | `setAllowedTargets(int ignored)`
    `` | `public void` | `setClassRetention(boolean ignored)`
    `` | `public void` | `setMember(String name, Expression value)`
    `` | `public void` | `setRuntimeRetention(boolean ignored)`
    `` | `public void` | `setSourceRetention(boolean ignored)`
    `` | `public static String` | `targetToName(int target)`
    `` | `public String` | `toString()`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class ASTNode` | `copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, getText, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePosition, visit`

- - ### Field Detail

    - #### public static final int ANNOTATION_TARGET

    - #### public static final int CONSTRUCTOR_TARGET

    - #### public static final int FIELD_TARGET

    - #### public static final int IMPORT_TARGET

      Groovy-only target for annotations on import statements.

    - #### public static final int LOCAL_VARIABLE_TARGET

    - #### public static final int METHOD_TARGET

    - #### public static final int PACKAGE_TARGET

    - #### public static final int PARAMETER_TARGET

    - #### public static final int RECORD_COMPONENT_TARGET

    - #### public static final int STATEMENT_TARGET

      Groovy-only target for statement-level annotations (e.g. on `for`/`while` loops).

    - #### public static final int TYPE_PARAMETER_TARGET

    - #### public static final int TYPE_TARGET

    - #### public static final int TYPE_USE_TARGET

  - ### Constructor Detail

    - #### public AnnotationNode(ClassNode type)

  - ### Method Detail

    - #### public void addMember(String name, Expression value)

    - #### public ClassNode getClassNode()

    - #### public Expression getMember(String name)

    - #### public Map<String, Expression> getMembers()

    - #### public String getText()

    - #### public boolean hasClassRetention()

      Flag corresponding to `RetentionPolicy.CLASS`. This is the default when no `Retention` annotation is present.

      Returns:
        `true` if the annotation is written in the bytecode but not visible at runtime; `false` otherwise

    - #### public boolean hasRuntimeRetention()

      Flag corresponding to `RetentionPolicy.RUNTIME`.

      Returns:
        `true` if the annotation should be visible at runtime; `false` otherwise

    - #### public boolean hasSourceRetention()

      Flag corresponding to `RetentionPolicy.SOURCE`.

      Returns:
        `true` if the annotation is only allowed in sources; `false` otherwise

    - #### @Deprecated(since = "6.0.0")
      public boolean isBuiltIn()

    - #### public boolean isTargetAllowed(int target)

    - #### @Deprecated(since = "6.0.0")
      public void setAllowedTargets(int ignored)

    - #### @Deprecated(since = "6.0.0")
      public void setClassRetention(boolean ignored)

    - #### public void setMember(String name, Expression value)

    - #### @Deprecated(since = "6.0.0")
      public void setRuntimeRetention(boolean ignored)

    - #### @Deprecated(since = "6.0.0")
      public void setSourceRetention(boolean ignored)

    - #### public static String targetToName(int target)

    - #### public String toString()