Package org.codehaus.groovy.ast

# Class PropertyNode

java.lang.Object
org.codehaus.groovy.ast.ASTNode
org.codehaus.groovy.ast.AnnotatedNode
org.codehaus.groovy.ast.PropertyNode

All Implemented Interfaces:
  `GroovydocHolder<AnnotatedNode>`, `NodeMetaDataHandler`, `Variable`

public class PropertyNode extends AnnotatedNode implements Variable
Represents a property (member variable, a getter and setter)

- ## Field Summary

  ### Fields inherited from interface groovy.lang.groovydoc.GroovydocHolder

  `DOC_COMMENT`

- ## Constructor Summary

  Constructors
  Constructor
  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.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `FieldNode`
  `getField()`
  Returns the backing field node for this property.
  `Statement`
  `getGetterBlock()`
  Returns the statement block that implements the getter method.
  `String`
  `getGetterName()`
  Returns the explicitly set getter method name for this property.
  `String`
  `getGetterNameOrDefault()`
  Returns the default getter method name for this property.
  `Expression`
  `getInitialExpression()`
  Returns the initial value expression for this property (delegated to backing field).
  `int`
  `getModifiers()`
  Returns the ASM modifier flags for this property.
  `String`
  `getName()`
  Returns the property name (delegated to backing field).
  `ClassNode`
  `getOriginType()`
  Returns the original property type before any transformations (delegated to backing field).
  `Statement`
  `getSetterBlock()`
  Returns the statement block that implements the setter method.
  `String`
  `getSetterName()`
  Returns the explicitly set setter method name for this property.
  `String`
  `getSetterNameOrDefault()`
  Returns the default setter method name for this property.
  `ClassNode`
  `getType()`
  Returns the property type (delegated to backing field).
  `boolean`
  `hasInitialExpression()`
  Checks whether this property has an initial value expression (delegated to backing field).
  `boolean`
  `isDynamicTyped()`
  Checks whether this property has dynamic typing (delegated to backing field).
  `boolean`
  `isInStaticContext()`
  Checks whether this property is in a static context (delegated to backing field).
  `void`
  `setField(FieldNode field)`
  Sets the backing field node for this property.
  `void`
  `setGetterBlock(Statement getterBlock)`
  Sets the statement block that implements the getter method.
  `void`
  `setGetterName(String getterName)`
  Sets an explicit getter method name for this property.
  `void`
  `setModifiers(int modifiers)`
  Sets the ASM modifier flags for this property.
  `void`
  `setSetterBlock(Statement setterBlock)`
  Sets the statement block that implements the setter method.
  `void`
  `setSetterName(String setterName)`
  Sets an explicit setter method name for this property.
  `void`
  `setType(ClassNode t)`
  Sets the property type (updates backing field's type).

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

  `addAnnotation, addAnnotation, addAnnotations, getAnnotations, getAnnotations, getDeclaringClass, getGroovydoc, getInstance, hasNoRealSourcePosition, isSynthetic, setDeclaringClass, setHasNoRealSourcePosition, setSynthetic`

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

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

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

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

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

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

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

  `isClosureSharedVariable, isFinal, isPrivate, isProtected, isPublic, isStatic, isVolatile, setClosureSharedVariable`

- ## Constructor Details

  - ### PropertyNode

    public 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). The property is synthesized from a field name, type, and optionally initial value expression, with getter and setter blocks.
    Parameters:
      `name` - the property name
      `modifiers` - ASM modifier flags (applied to the property, with static flag removed from field)
      `type` - the property type as a `ClassNode`
      `owner` - the `ClassNode` that declares this property
      `initialValueExpression` - optional initial value expression
      `getterBlock` - optional statement block for the getter method body
      `setterBlock` - optional statement block for the setter method body

  - ### PropertyNode

    public PropertyNode(FieldNode field, int modifiers, Statement getterBlock, Statement setterBlock)
    Creates a property node from an existing field and getter/setter blocks. This constructor allows properties to be built from pre-existing field definitions.
    Parameters:
      `field` - the `FieldNode` backing this property
      `modifiers` - ASM modifier flags for the property
      `getterBlock` - optional statement block for the getter method body
      `setterBlock` - optional statement block for the setter method body

- ## Method Details

  - ### getField

    public FieldNode getField()
    Returns the backing field node for this property.
    Returns:
      the `FieldNode` associated with this property

  - ### setField

    public void setField(FieldNode field)
    Sets the backing field node for this property.
    Parameters:
      `field` - the `FieldNode` to associate with this property

  - ### getModifiers

    public int getModifiers()
    Returns the ASM modifier flags for this property.
    Specified by:
      `getModifiers` in interface `Variable`
    Returns:
      ASM opcode flags representing this property's modifiers
    See Also:
      - `Opcodes`

  - ### setModifiers

    public void setModifiers(int modifiers)
    Sets the ASM modifier flags for this property.
    Parameters:
      `modifiers` - ASM opcode flags to set

  - ### getGetterBlock

    public Statement getGetterBlock()
    Returns the statement block that implements the getter method. Returns null if no explicit getter implementation is provided.
    Returns:
      the getter block statement, or null

  - ### setGetterBlock

    public void setGetterBlock(Statement getterBlock)
    Sets the statement block that implements the getter method.
    Parameters:
      `getterBlock` - the getter implementation statement

  - ### getSetterBlock

    public Statement getSetterBlock()
    Returns the statement block that implements the setter method. Returns null if no explicit setter implementation is provided.
    Returns:
      the setter block statement, or null

  - ### setSetterBlock

    public void setSetterBlock(Statement setterBlock)
    Sets the statement block that implements the setter method.
    Parameters:
      `setterBlock` - the setter implementation statement

  - ### getGetterName

    public String getGetterName()
    Returns the explicitly set getter method name for this property. Returns null if no explicit name has been set (use `getGetterNameOrDefault()` instead).
    Returns:
      the explicit getter name, or null if not set
    Since:
      4.0.0

  - ### setGetterName

    public void setGetterName(String getterName)
    Sets an explicit getter method name for this property. Overrides the default naming convention (getFoo/isFoo). Throws IllegalArgumentException if the name is null or empty.
    Parameters:
      `getterName` - the getter method name (non-null, non-empty)
    Throws:
      `IllegalArgumentException` - if name is null or empty
    Since:
      4.0.0

  - ### getSetterName

    public String getSetterName()
    Returns the explicitly set setter method name for this property. Returns null if no explicit name has been set (use `getSetterNameOrDefault()` instead).
    Returns:
      the explicit setter name, or null if not set
    Since:
      4.0.0

  - ### setSetterName

    public void setSetterName(String setterName)
    Sets an explicit setter method name for this property. Overrides the default naming convention (setFoo). Throws IllegalArgumentException if the name is null or empty.
    Parameters:
      `setterName` - the setter method name (non-null, non-empty)
    Throws:
      `IllegalArgumentException` - if name is null or empty
    Since:
      4.0.0

  - ### getName

    public String getName()
    Returns the property name (delegated to backing field).
    Specified by:
      `getName` in interface `Variable`
    Returns:
      the property identifier

  - ### getType

    public ClassNode getType()
    Returns the property type (delegated to backing field).
    Specified by:
      `getType` in interface `Variable`
    Returns:
      the property's `ClassNode` type

  - ### getOriginType

    public ClassNode getOriginType()
    Returns the original property type before any transformations (delegated to backing field).
    Specified by:
      `getOriginType` in interface `Variable`
    Returns:
      the original `ClassNode` type

  - ### setType

    public void setType(ClassNode t)
    Sets the property type (updates backing field's type).
    Parameters:
      `t` - the new property `ClassNode` type

  - ### getInitialExpression

    public Expression getInitialExpression()
    Returns the initial value expression for this property (delegated to backing field).
    Specified by:
      `getInitialExpression` in interface `Variable`
    Returns:
      the initial value `Expression`, or null if absent

  - ### hasInitialExpression

    public boolean hasInitialExpression()
    Checks whether this property has an initial value expression (delegated to backing field).
    Specified by:
      `hasInitialExpression` in interface `Variable`
    Returns:
      true if an initializer expression is present

  - ### isInStaticContext

    public boolean isInStaticContext()
    Checks whether this property is in a static context (delegated to backing field).
    Specified by:
      `isInStaticContext` in interface `Variable`
    Returns:
      true if the backing field is static

  - ### isDynamicTyped

    public boolean isDynamicTyped()
    Checks whether this property has dynamic typing (delegated to backing field).
    Specified by:
      `isDynamicTyped` in interface `Variable`
    Returns:
      true if the backing field's type is dynamically typed

  - ### getGetterNameOrDefault

    public String getGetterNameOrDefault()
    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 getter method name (either explicit or default)
    Since:
      4.0.0

  - ### getSetterNameOrDefault

    public String getSetterNameOrDefault()
    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 setter method name (either explicit or default)
    Since:
      4.0.0