public class FieldNode
extends AnnotatedNode
implements Variable
Represents a field (member variable)
| Type Params | Return Type | Name and description |
|---|---|---|
|
public boolean |
equals(Object obj) |
|
public Expression |
getInitialExpression()Returns the initial value expression for this field. |
|
public Expression |
getInitialValueExpression()Returns the initial value expression for this field. |
|
public int |
getModifiers()Returns the ASM modifier flags for this field. |
|
public String |
getName()Returns the field name. |
|
public ClassNode |
getOriginType()Returns the original declared type of this field before any transformations. |
|
public ClassNode |
getOwner()Returns the class that declares this field. |
|
public ClassNode |
getType()Returns the declared type of this field as a ClassNode. |
|
public boolean |
hasInitialExpression()Checks whether this field has an initial value expression. |
|
public boolean |
isDynamicTyped()Checks whether this field's type is dynamically typed (unresolved type). |
|
public boolean |
isEnum()Checks whether this field is an enum constant. |
|
public boolean |
isHolder()Checks whether this field is a holder field. |
|
public boolean |
isInStaticContext()Checks whether this field is in a static context. |
|
public static FieldNode |
newStatic(Class theClass, String name)Creates a new FieldNode wrapping a reflection Field from a Java class. |
|
public void |
rename(String name)Renames this field within its declaring class. |
|
public void |
setHolder(boolean holder)Marks this field as a holder field for internal compilation purposes. |
|
public void |
setInitialValueExpression(Expression initialValueExpression)Sets the initial value expression for this field. |
|
public void |
setModifiers(int modifiers)Sets the ASM modifier flags for this field. |
|
public void |
setOriginType(ClassNode cn)Sets the original type information for this field. |
|
public void |
setOwner(ClassNode owner)Sets the class that declares this field. |
|
public void |
setType(ClassNode type)Sets the field's type. |
| Methods inherited from class | Name |
|---|---|
class AnnotatedNode |
addAnnotation, addAnnotation, addAnnotations, getAnnotations, getAnnotations, getDeclaringClass, getGroovydoc, getInstance, hasNoRealSourcePosition, isSynthetic, setDeclaringClass, setHasNoRealSourcePosition, setSynthetic |
class ASTNode |
copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, getText, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePosition, visit |
Creates a field node representing a class member variable. The field's type can be dynamically determined based on the provided ClassNode.
Returns the initial value expression for this field. The expression is evaluated when the field is initialized. Returns null if no initializer is present.
Returns the initial value expression for this field. Provides direct access to the initializer expression if one is defined.
Returns the ASM modifier flags for this field. Flags include visibility (public/protected/private), static, final, transient, volatile, etc.
Returns the field name.
Returns the original declared type of this field before any transformations. Useful for preserving type information through compilation phases that may modify types.
Returns the class that declares this field.
Returns the declared type of this field as a ClassNode. The type may be dynamically determined or may reference generics.
Checks whether this field has an initial value expression.
Checks whether this field's type is dynamically typed (unresolved type). Dynamic typing occurs when the exact type cannot be determined at compile time.
Checks whether this field is an enum constant. Enum constants are fields with the ACC_ENUM access flag.
Checks whether this field is a holder field. Holder fields are used internally for certain compilation strategies.
Checks whether this field is in a static context. A field is in a static context if it has the static modifier.
Creates a new FieldNode wrapping a reflection Field from a Java class. Extracts type information from the reflected field and creates an AST representation with public static access modifiers matching the source field.
theClass - the class containing the reflected fieldname - the field nameRenames this field within its declaring class. Updates both the AST node and the declaring class's field registry.
name - the new field nameMarks this field as a holder field for internal compilation purposes.
holder - true to mark as a holder fieldSets the initial value expression for this field. The expression will be evaluated during field initialization.
initialValueExpression - the Expression for initialization, or nullSets the ASM modifier flags for this field. Allows updating visibility or other modifier flags during compilation.
modifiers - ASM opcode flags to setSets the original type information for this field. Typically set during type transformation to preserve original type metadata.
cn - the original ClassNode typeSets the class that declares this field. Used during AST construction to establish the ownership relationship.
owner - the declaring ClassNodeCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.