public class PropertyNode
extends AnnotatedNode
implements Variable
Represents a property (member variable, a getter and setter)
| Constructor and description |
|---|
PropertyNode(String name, int modifiers, ClassNode type, ClassNode owner, Expression initialValueExpression, Statement getterBlock, Statement setterBlock)Creates a property node representing a Java property (field + getter/setter). |
PropertyNode(FieldNode field, int modifiers, Statement getterBlock, Statement setterBlock)Creates a property node from an existing field and getter/setter blocks. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public FieldNode |
getField()Returns the backing field node for this property. |
|
public Statement |
getGetterBlock()Returns the statement block that implements the getter method. |
|
public String |
getGetterName()Returns the explicitly set getter method name for this property. |
|
public String |
getGetterNameOrDefault()Returns the default getter method name for this property. |
|
public Expression |
getInitialExpression()Returns the initial value expression for this property (delegated to backing field). |
|
public int |
getModifiers()Returns the ASM modifier flags for this property. |
|
public String |
getName()Returns the property name (delegated to backing field). |
|
public ClassNode |
getOriginType()Returns the original property type before any transformations (delegated to backing field). |
|
public Statement |
getSetterBlock()Returns the statement block that implements the setter method. |
|
public String |
getSetterName()Returns the explicitly set setter method name for this property. |
|
public String |
getSetterNameOrDefault()Returns the default setter method name for this property. |
|
public ClassNode |
getType()Returns the property type (delegated to backing field). |
|
public boolean |
hasInitialExpression()Checks whether this property has an initial value expression (delegated to backing field). |
|
public boolean |
isDynamicTyped()Checks whether this property has dynamic typing (delegated to backing field). |
|
public boolean |
isInStaticContext()Checks whether this property is in a static context (delegated to backing field). |
|
public void |
setField(FieldNode field)Sets the backing field node for this property. |
|
public void |
setGetterBlock(Statement getterBlock)Sets the statement block that implements the getter method. |
|
public void |
setGetterName(String getterName)Sets an explicit getter method name for this property. |
|
public void |
setModifiers(int modifiers)Sets the ASM modifier flags for this property. |
|
public void |
setSetterBlock(Statement setterBlock)Sets the statement block that implements the setter method. |
|
public void |
setSetterName(String setterName)Sets an explicit setter method name for this property. |
|
public void |
setType(ClassNode t)Sets the property type (updates backing 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 property node representing a Java property (field + getter/setter). The property is synthesized from a field name, type, and optionally initial value expression, with getter and setter blocks.
name - the property namemodifiers - ASM modifier flags (applied to the property, with static flag removed from field)type - the property type as a ClassNodeowner - the ClassNode that declares this propertyinitialValueExpression - optional initial value expressiongetterBlock - optional statement block for the getter method bodysetterBlock - optional statement block for the setter method bodyCreates a property node from an existing field and getter/setter blocks. This constructor allows properties to be built from pre-existing field definitions.
field - the FieldNode backing this propertymodifiers - ASM modifier flags for the propertygetterBlock - optional statement block for the getter method bodysetterBlock - optional statement block for the setter method bodyReturns the backing field node for this property.
Returns the statement block that implements the getter method. Returns null if no explicit getter implementation is provided.
Returns the explicitly set getter method name for this property. Returns null if no explicit name has been set (use getGetterNameOrDefault() instead).
Returns the default getter method name for this property.
If an explicit name has been set, returns that; otherwise returns the conventional name.
For a property foo, the default name is getFoo except for a boolean property where
isFoo is the default if no getFoo method exists in the declaring class.
Returns the initial value expression for this property (delegated to backing field).
Returns the ASM modifier flags for this property.
Returns the property name (delegated to backing field).
Returns the original property type before any transformations (delegated to backing field).
Returns the statement block that implements the setter method. Returns null if no explicit setter implementation is provided.
Returns the explicitly set setter method name for this property. Returns null if no explicit name has been set (use getSetterNameOrDefault() instead).
Returns the default setter method name for this property.
If an explicit name has been set, returns that; otherwise returns the conventional name.
For a property foo, the default name is setFoo.
Returns the property type (delegated to backing field).
Checks whether this property has an initial value expression (delegated to backing field).
Checks whether this property has dynamic typing (delegated to backing field).
Checks whether this property is in a static context (delegated to backing field).
Sets the backing field node for this property.
field - the FieldNode to associate with this propertySets the statement block that implements the getter method.
getterBlock - the getter implementation statementSets an explicit getter method name for this property. Overrides the default naming convention (getFoo/isFoo). Throws IllegalArgumentException if the name is null or empty.
getterName - the getter method name (non-null, non-empty)Sets the ASM modifier flags for this property.
modifiers - ASM opcode flags to setSets the statement block that implements the setter method.
setterBlock - the setter implementation statementSets an explicit setter method name for this property. Overrides the default naming convention (setFoo). Throws IllegalArgumentException if the name is null or empty.
setterName - the setter method name (non-null, non-empty)Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.