Package org.codehaus.groovy.ast

# Class AnnotationNode

java.lang.Object
org.codehaus.groovy.ast.ASTNode
org.codehaus.groovy.ast.AnnotationNode

All Implemented Interfaces:
  `NodeMetaDataHandler`

public class AnnotationNode extends ASTNode
Represents an annotation which can be attached to interfaces, classes, methods, fields, parameters, and other places.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `ANNOTATION_TARGET`
  `static final int`
  `CONSTRUCTOR_TARGET`
  `static final int`
  `FIELD_TARGET`
  `static final int`
  `IMPORT_TARGET`
  Groovy-only target for annotations on import statements.
  `static final int`
  `LOCAL_VARIABLE_TARGET`
  `static final int`
  `METHOD_TARGET`
  `static final int`
  `PACKAGE_TARGET`
  `static final int`
  `PARAMETER_TARGET`
  `static final int`
  `RECORD_COMPONENT_TARGET`
  `static final int`
  `STATEMENT_TARGET`
  Groovy-only target for statement-level annotations (e.g.
  `static final int`
  `TYPE_PARAMETER_TARGET`
  `static final int`
  `TYPE_TARGET`
  `static final int`
  `TYPE_USE_TARGET`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AnnotationNode(ClassNode type)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addMember(String name, Expression value)`
  `ClassNode`
  `getClassNode()`
  `Expression`
  `getMember(String name)`
  `Map<String,Expression>`
  `getMembers()`
  `String`
  `getText()`
  Returns a human-readable text representation of this AST node.
  `boolean`
  `hasClassRetention()`
  Flag corresponding to `RetentionPolicy.CLASS`.
  `boolean`
  `hasRuntimeRetention()`
  Flag corresponding to `RetentionPolicy.RUNTIME`.
  `boolean`
  `hasSourceRetention()`
  Flag corresponding to `RetentionPolicy.SOURCE`.
  `boolean`
  `isBuiltIn()`
  Deprecated.
  `boolean`
  `isTargetAllowed(int target)`
  `void`
  `setAllowedTargets(int ignored)`
  Deprecated.
  `void`
  `setClassRetention(boolean ignored)`
  Deprecated.
  `void`
  `setMember(String name, Expression value)`
  `void`
  `setRuntimeRetention(boolean ignored)`
  Deprecated.
  `void`
  `setSourceRetention(boolean ignored)`
  Deprecated.
  `static String`
  `targetToName(int target)`
  `String`
  `toString()`

  ### Methods inherited from class org.codehaus.groovy.ast.ASTNode

  `copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePosition, visit`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface org.codehaus.groovy.ast.NodeMetaDataHandler

  `copyNodeMetaData, getNodeMetaData, getNodeMetaData, getNodeMetaData, newMetaDataMap, putNodeMetaData, removeNodeMetaData, setNodeMetaData`

- ## Field Details

  - ### CONSTRUCTOR_TARGET

    public static final int CONSTRUCTOR_TARGET
    See Also:
      - Constant Field Values

  - ### METHOD_TARGET

    public static final int METHOD_TARGET
    See Also:
      - Constant Field Values

  - ### FIELD_TARGET

    public static final int FIELD_TARGET
    See Also:
      - Constant Field Values

  - ### PARAMETER_TARGET

    public static final int PARAMETER_TARGET
    See Also:
      - Constant Field Values

  - ### LOCAL_VARIABLE_TARGET

    public static final int LOCAL_VARIABLE_TARGET
    See Also:
      - Constant Field Values

  - ### ANNOTATION_TARGET

    public static final int ANNOTATION_TARGET
    See Also:
      - Constant Field Values

  - ### PACKAGE_TARGET

    public static final int PACKAGE_TARGET
    See Also:
      - Constant Field Values

  - ### TYPE_PARAMETER_TARGET

    public static final int TYPE_PARAMETER_TARGET
    See Also:
      - Constant Field Values

  - ### TYPE_USE_TARGET

    public static final int TYPE_USE_TARGET
    See Also:
      - Constant Field Values

  - ### RECORD_COMPONENT_TARGET

    public static final int RECORD_COMPONENT_TARGET
    See Also:
      - Constant Field Values

  - ### STATEMENT_TARGET

    public static final int STATEMENT_TARGET
    Groovy-only target for statement-level annotations (e.g. on `for`/`while` loops).
    See Also:
      - Constant Field Values

  - ### IMPORT_TARGET

    public static final int IMPORT_TARGET
    Groovy-only target for annotations on import statements.
    See Also:
      - Constant Field Values

  - ### TYPE_TARGET

    public static final int TYPE_TARGET
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### AnnotationNode

    public AnnotationNode(ClassNode type)

- ## Method Details

  - ### addMember

    public void addMember(String name, Expression value)

  - ### setMember

    public void setMember(String name, Expression value)

  - ### setAllowedTargets

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

  - ### setClassRetention

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

  - ### setSourceRetention

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

  - ### setRuntimeRetention

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

  - ### getClassNode

    public ClassNode getClassNode()

  - ### getMembers

    public Map<String,Expression> getMembers()

  - ### getMember

    public Expression getMember(String name)

  - ### isBuiltIn

    @Deprecated(since="6.0.0") public boolean isBuiltIn()
    Deprecated.

  - ### isTargetAllowed

    public boolean isTargetAllowed(int target)

  - ### hasRuntimeRetention

    public boolean hasRuntimeRetention()
    Flag corresponding to `RetentionPolicy.RUNTIME`.
    Returns:
      `true` if the annotation should be visible at runtime; `false` otherwise

  - ### hasSourceRetention

    public boolean hasSourceRetention()
    Flag corresponding to `RetentionPolicy.SOURCE`.
    Returns:
      `true` if the annotation is only allowed in sources; `false` otherwise

  - ### hasClassRetention

    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

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### getText

    public String getText()
    Description copied from class: `ASTNode`
    Returns a human-readable text representation of this AST node. Used for debugging and error messages. Default implementation returns a message indicating the representation is not yet implemented for this node type.
    Overrides:
      `getText` in class `ASTNode`
    Returns:
      text representation of this node, or placeholder for unimplemented types

  - ### targetToName

    public static String targetToName(int target)