Class 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:
  • 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 AnnotationNodes 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