Package: org.codehaus.groovy.ast

## [Java] Class PropertyNode

- org.codehaus.groovy.ast.PropertyNode

- All Implemented Interfaces and Traits:
    Variable

      public class PropertyNode
      extends AnnotatedNode
      implements Variable

  Represents a property (member variable, a getter and setter)

- - ### Constructor Summary

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

  - ### Methods Summary

    Methods
    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).

  - ### Inherited Methods Summary

    Inherited Methods
    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`

- - ### Constructor Detail

    - #### 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

    - #### 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 Detail

    - #### public FieldNode getField()

      Returns the backing field node for this property.

      Returns:
        the FieldNode associated with this property

    - #### 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

    - #### 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

    - #### 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

    - #### public Expression getInitialExpression()

      Returns the initial value expression for this property (delegated to backing field).

      Returns:
        the initial value Expression, or null if absent

    - #### public int getModifiers()

      Returns the ASM modifier flags for this property.

      Returns:
        ASM opcode flags representing this property's modifiers

    - #### public String getName()

      Returns the property name (delegated to backing field).

      Returns:
        the property identifier

    - #### public ClassNode getOriginType()

      Returns the original property type before any transformations (delegated to backing field).

      Returns:
        the original ClassNode type

    - #### 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

    - #### 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

    - #### 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

    - #### public ClassNode getType()

      Returns the property type (delegated to backing field).

      Returns:
        the property's ClassNode type

    - #### public boolean hasInitialExpression()

      Checks whether this property has an initial value expression (delegated to backing field).

      Returns:
        true if an initializer expression is present

    - #### public boolean isDynamicTyped()

      Checks whether this property has dynamic typing (delegated to backing field).

      Returns:
        true if the backing field's type is dynamically typed

    - #### public boolean isInStaticContext()

      Checks whether this property is in a static context (delegated to backing field).

      Returns:
        true if the backing field is static

    - #### public void setField(FieldNode field)

      Sets the backing field node for this property.

      Parameters:
        `field` - the FieldNode to associate with this property

    - #### public void setGetterBlock(Statement getterBlock)

      Sets the statement block that implements the getter method.

      Parameters:
        `getterBlock` - the getter implementation statement

    - #### 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.

      throws:
        IllegalArgumentException if name is null or empty
      Parameters:
        `getterName` - the getter method name (non-null, non-empty)
      Since:
        4.0.0

    - #### public void setModifiers(int modifiers)

      Sets the ASM modifier flags for this property.

      Parameters:
        `modifiers` - ASM opcode flags to set

    - #### public void setSetterBlock(Statement setterBlock)

      Sets the statement block that implements the setter method.

      Parameters:
        `setterBlock` - the setter implementation statement

    - #### 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.

      throws:
        IllegalArgumentException if name is null or empty
      Parameters:
        `setterName` - the setter method name (non-null, non-empty)
      Since:
        4.0.0

    - #### public void setType(ClassNode t)

      Sets the property type (updates backing field's type).

      Parameters:
        `t` - the new property ClassNode type