[Java] Class AnnotationNode
- org.codehaus.groovy.ast.AnnotationNode
Represents an annotation which can be attached to interfaces, classes, methods, fields, parameters, and other places.
Field Summary
Modifiers | Name | 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 |
Properties Summary
Type | Name and description |
---|---|
Expression |
member |
Constructor Summary
Constructor and description |
---|
AnnotationNode
(ClassNode classNode) |
Methods Summary
Type Params | Return Type | Name and description |
---|---|---|
void |
addMember(String name, Expression value) | |
ClassNode |
getClassNode() | |
Expression |
getMember(String name) | |
Map<String, Expression> |
getMembers() | |
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(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 String |
targetToName(int target) |
Inherited Methods Summary
Methods inherited from class | Name |
---|---|
class ASTNode | copyNodeMetaData, equals, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, getNodeMetaData, getNodeMetaData, getText, hashCode, putNodeMetaData, removeNodeMetaData, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setNodeMetaData, 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 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 TYPE_PARAMETER_TARGET
public static final int TYPE_TARGET
public static final int TYPE_USE_TARGET
Property Detail
Expression member
Constructor Detail
public AnnotationNode(ClassNode classNode)
Method Detail
public void addMember(String name, Expression value)
public ClassNode getClassNode()
public Expression getMember(String name)
public Map<String, Expression> getMembers()
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
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
public boolean isBuiltIn()
public boolean isTargetAllowed(int target)
public void setAllowedTargets(int bitmap)
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 havingRetentionPolicy.CLASS
.
public void setMember(String name, Expression value)
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 havingRetentionPolicy.RUNTIME
.
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 havingRetentionPolicy.SOURCE
.
public static String targetToName(int target)
© 2003-2020 The Apache Software Foundation
Licensed under the Apache license.
https://docs.groovy-lang.org/2.5.14/html/gapi/org/codehaus/groovy/ast/AnnotationNode.html