Package org.codehaus.groovy.ast

# Class RecordComponentNode

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

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

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.

Since:
  4.0.0
See Also:
  - `ClassNode`
  - `AnnotatedNode`

- ## Field Summary

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

  `DOC_COMMENT`

- ## Constructor Summary

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

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object o)`
  Compares this record component with another object for equality.
  `String`
  `getName()`
  Returns the name of this record component.
  `ClassNode`
  `getType()`
  Returns the type of this record component.
  `int`
  `hashCode()`
  Returns the hash code for this record component based on its name and declaring class.

  ### 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, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

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

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

- ## Constructor Details

  - ### RecordComponentNode

    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)

  - ### RecordComponentNode

    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 `AnnotationNode`s to attach to this component

- ## Method Details

  - ### getName

    public String getName()
    Returns the name of this record component.
    Returns:
      the component name

  - ### getType

    public ClassNode getType()
    Returns the type of this record component.
    Returns:
      the `ClassNode` representing this component's type

  - ### equals

    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.
    Overrides:
      `equals` in class `Object`
    Parameters:
      `o` - the object to compare with
    Returns:
      true if the objects represent the same record component

  - ### hashCode

    public int hashCode()
    Returns the hash code for this record component based on its name and declaring class.
    Overrides:
      `hashCode` in class `Object`
    Returns:
      the hash code