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
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:
-
Field Summary
Fields inherited from interface groovy.lang.groovydoc.GroovydocHolder
DOC_COMMENT -
Constructor Summary
ConstructorsConstructorDescriptionRecordComponentNode(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 TypeMethodDescriptionbooleanCompares this record component with another object for equality.getName()Returns the name of this record component.getType()Returns the type of this record component.inthashCode()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, setSyntheticMethods inherited from class org.codehaus.groovy.ast.ASTNode
copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, getText, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePosition, visitMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.codehaus.groovy.ast.NodeMetaDataHandler
copyNodeMetaData, getNodeMetaData, getNodeMetaData, getNodeMetaData, newMetaDataMap, putNodeMetaData, removeNodeMetaData, setNodeMetaData
-
Constructor Details
-
RecordComponentNode
Creates a record component with the specified name and type. -
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- theClassNodethat declares this record componentname- the name of the record component (never null)type- theClassNoderepresenting the component's type (never null)annotations- a list ofAnnotationNodes to attach to this component
-
-
Method Details
-
getName
Returns the name of this record component.- Returns:
- the component name
-
getType
Returns the type of this record component.- Returns:
- the
ClassNoderepresenting this component's type
-
equals
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. -
hashCode
public int hashCode()Returns the hash code for this record component based on its name and declaring class.
-