Package: org.codehaus.groovy.ast

## [Java] Class RecordComponentNode

- org.codehaus.groovy.ast.RecordComponentNode

-     public class RecordComponentNode
      extends AnnotatedNode

  Represents a component (field) of a record class definition introduced in Java 16. Record components provide immutable fields with automatic generation of accessor methods, constructor parameters, and `equals()`/`hashCode()`/`toString()` implementations. Each component maintains its type and any annotations applied to it.

  See Also:
    ClassNode
    AnnotatedNode
  Since:
    4.0.0

- - ### Constructor Summary

    Constructors
    Constructor and description
    `RecordComponentNode(ClassNode declaringClass, String name, ClassNode type)` Creates a record component with the specified name and type.
    `RecordComponentNode(ClassNode declaringClass, String name, ClassNode type, List<AnnotationNode> annotations)` Creates a record component with the specified name, type, and annotations.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public boolean` | `equals(Object o)` Compares this record component with another object for equality.
    `` | `public String` | `getName()` Returns the name of this record component.
    `` | `public ClassNode` | `getType()` Returns the type of this record component.
    `` | `public int` | `hashCode()` Returns the hash code for this record component based on its name and declaring class.

  - ### 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 RecordComponentNode(ClassNode declaringClass, String name, ClassNode type)

      Creates a record component with the specified name and type.

      Parameters:
        `declaringClass` - the ClassNode that declares this record component
        `name` - the name of the record component (never null)
        `type` - the ClassNode representing the component's type (never null)

    - #### public RecordComponentNode(ClassNode declaringClass, String name, ClassNode type, List<AnnotationNode> annotations)

      Creates a record component with the specified name, type, and annotations. Annotations are applied to this component in the order provided.

      Parameters:
        `declaringClass` - the ClassNode that declares this record component
        `name` - the name of the record component (never null)
        `type` - the ClassNode representing the component's type (never null)
        `annotations` - a list of AnnotationNodes to attach to this component

  - ### Method Detail

    - #### public boolean equals(Object o)

      Compares this record component with another object for equality. Two components are equal if they have the same name and belong to the same declaring class.

      Parameters:
        `o` - the object to compare with
      Returns:
        true if the objects represent the same record component

    - #### public String getName()

      Returns the name of this record component.

      Returns:
        the component name

    - #### public ClassNode getType()

      Returns the type of this record component.

      Returns:
        the ClassNode representing this component's type

    - #### public int hashCode()

      Returns the hash code for this record component based on its name and declaring class.

      Returns:
        the hash code