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 int` | `ANNOTATION_TARGET` |
  `static int` | `CONSTRUCTOR_TARGET` |
  `static int` | `FIELD_TARGET` |
  `static int` | `LOCAL_VARIABLE_TARGET` |
  `static int` | `METHOD_TARGET` |
  `static int` | `PACKAGE_TARGET` |
  `static int` | `PARAMETER_TARGET` |
  `static int` | `TYPE_PARAMETER_TARGET` |
  `static int` | `TYPE_TARGET` |
  `static int` | `TYPE_USE_TARGET` |

- ## Constructor Summary

  Constructors
  Constructor | Description
  --- | ---
  `AnnotationNode​(ClassNode classNode)` |

- ## Method Summary

  Modifier and Type | Method | Description
  --- | --- | ---
  `void` | `addMember​(java.lang.String name, Expression value)` |
  `ClassNode` | `getClassNode()` |
  `Expression` | `getMember​(java.lang.String name)` |
  `java.util.Map<java.lang.String,​Expression>` | `getMembers()` |
  `java.lang.String` | `getText()` |
  `boolean` | `hasClassRetention()` | Flag corresponding to `RetentionPolicy.CLASS`.
  `boolean` | `hasRuntimeRetention()` | Flag corresponding to `RetentionPolicy.RUNTIME`.
  `boolean` | `hasSourceRetention()` | Flag corresponding to `RetentionPolicy.SOURCE`.
  `boolean` | `isBuiltIn()` |
  `boolean` | `isTargetAllowed​(int target)` |
  `void` | `setAllowedTargets​(int bitmap)` |
  `void` | `setClassRetention​(boolean flag)` | Sets the internal flag if the current annotation has an explicit `RetentionPolicy.CLASS`.
  `void` | `setMember​(java.lang.String name, Expression value)` |
  `void` | `setRuntimeRetention​(boolean flag)` | Sets the internal flag if the current annotation has `RetentionPolicy.SOURCE`.
  `void` | `setSourceRetention​(boolean flag)` | Sets the internal flag if the current annotation has `RetentionPolicy.SOURCE`.
  `static java.lang.String` | `targetToName​(int target)` |
  `java.lang.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, 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

  - ### TYPE_TARGET

    public static final int TYPE_TARGET
    See Also:
      Constant Field Values

- ## Constructor Details

  - ### AnnotationNode

    public AnnotationNode​(ClassNode classNode)

- ## Method Details

  - ### getClassNode

    public ClassNode getClassNode()

  - ### getMembers

    public java.util.Map<java.lang.String,​Expression> getMembers()

  - ### getMember

    public Expression getMember​(java.lang.String name)

  - ### addMember

    public void addMember​(java.lang.String name, Expression value)

  - ### setMember

    public void setMember​(java.lang.String name, Expression value)

  - ### isBuiltIn

    public boolean isBuiltIn()

  - ### hasRuntimeRetention

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

  - ### setRuntimeRetention

    public void setRuntimeRetention​(boolean flag)
    Sets the internal flag if the current annotation has `RetentionPolicy.SOURCE`.
    Parameters:
      `flag` - if `true` then current annotation is marked as having `RetentionPolicy.RUNTIME`.

  - ### hasSourceRetention

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

  - ### setSourceRetention

    public void setSourceRetention​(boolean flag)
    Sets the internal flag if the current annotation has `RetentionPolicy.SOURCE`.
    Parameters:
      `flag` - if `true` then current annotation is marked as having `RetentionPolicy.SOURCE`.

  - ### hasClassRetention

    public boolean hasClassRetention()
    Flag corresponding to `RetentionPolicy.CLASS`. This is the default when no `RetentionPolicy` annotations are present.
    Returns:
      `true` if the annotation is written in the bytecode, but not visible at runtime `false` otherwise

  - ### setClassRetention

    public void setClassRetention​(boolean flag)
    Sets the internal flag if the current annotation has an explicit `RetentionPolicy.CLASS`.
    Parameters:
      `flag` - if `true` then current annotation is marked as having `RetentionPolicy.CLASS`.

  - ### setAllowedTargets

    public void setAllowedTargets​(int bitmap)

  - ### isTargetAllowed

    public boolean isTargetAllowed​(int target)

  - ### targetToName

    public static java.lang.String targetToName​(int target)

  - ### toString

    public java.lang.String toString()
    Overrides:
      `toString` in class `java.lang.Object`

  - ### getText

    public java.lang.String getText()
    Overrides:
      `getText` in class `ASTNode`