Class RecordComponent
Since: 16 See Also:
-
Method Summary
All MethodsInstance MethodsConcrete MethodsModifier and TypeMethodDescriptionReturns a Method that represents the accessor for this record component.Returns an AnnotatedType object that represents the use of a type to specify the declared type of this record component.<T extends Annotation>
TgetAnnotation(Class<T> annotationClass)Returns this element's annotation for the specified type if such an annotation is present, else null.Returns annotations that are present on this element.Returns annotations that are directly present on this element.Class<?>Returns the record class which declares this record component.Returns a String that describes the generic type signature for this record component.Returns a Type object that represents the declared type for this record component.getName()Returns the name of this record component.Class<?>getType()Returns a Class that identifies the declared type for this record component.toString()Returns a string describing this record component.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Creates and returns a copy of this object.booleanIndicates whether some other object is "equal to" this one.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.Finalization is deprecated and subject to removal in a future release.final Class<?>getClass()Returns the runtime class of this Object.inthashCode()Returns a hash code value for this object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.final voidwait()Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final voidwait(long timeoutMillis)Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.final voidwait(long timeoutMillis, int nanos)Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.Methods declared in interface AnnotatedElement
getAnnotationsByType, getDeclaredAnnotation, getDeclaredAnnotationsByType, isAnnotationPresentModifier and TypeMethodDescriptiondefault <T extends Annotation>
T[]getAnnotationsByType(Class<T> annotationClass)Returns annotations that are associated with this element.default <T extends Annotation>
TgetDeclaredAnnotation(Class<T> annotationClass)Returns this element's annotation for the specified type if such an annotation is directly present, else null.default <T extends Annotation>
T[]getDeclaredAnnotationsByType(Class<T> annotationClass)Returns this element's annotation(s) for the specified type if such annotations are either directly present or indirectly present.default booleanReturns true if an annotation for the specified type is present on this element, else false.
-
Method Details
-
getName
Returns the name of this record component.Returns: the name of this record component -
getType
Returns a Class that identifies the declared type for this record component.Returns: a Class identifying the declared type of the component represented by this record component -
getGenericSignature
Returns a String that describes the generic type signature for this record component.Returns: a String that describes the generic type signature for this record component See Java Virtual Machine Specification: 4.7.9.1 Signatures
-
getGenericType
Returns a Type object that represents the declared type for this record component.Returns: a Type object that represents the declared type for this record component Throws: GenericSignatureFormatError - if the generic record component signature does not conform to the format specified in The Java Virtual Machine Specification TypeNotPresentException - if the generic type signature of the underlying record component refers to a non-existent type declaration MalformedParameterizedTypeException - if the generic signature of the underlying record component refers to a parameterized type that cannot be instantiated for any reasonIf the declared type of the record component is a parameterized type, the Type object returned reflects the actual type arguments used in the source code.
If the type of the underlying record component is a type variable or a parameterized type, it is created. Otherwise, it is resolved.
-
getAnnotatedType
Returns an AnnotatedType object that represents the use of a type to specify the declared type of this record component.Returns: an object representing the declared type of this record component -
getAccessor
Returns a Method that represents the accessor for this record component.Returns: a Method that represents the accessor for this record component -
getAnnotation
Returns this element's annotation for the specified type if such an annotation is present, else null.Specified by: getAnnotation in interface AnnotatedElement Type Parameters: T - the type of the annotation to query for and return if present Parameters: annotationClass - the Class object corresponding to the annotation type Returns: this element's annotation for the specified annotation type if present on this element, else null Throws: NullPointerException - if the given annotation class is nullNote that any annotation returned by this method is a declaration annotation.
-
getAnnotations
Returns annotations that are present on this element. If there are no annotations present on this element, the return value is an array of length 0. The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers.Specified by: getAnnotations in interface AnnotatedElement Returns: annotations present on this elementNote that any annotations returned by this method are declaration annotations.
-
getDeclaredAnnotations
Returns annotations that are directly present on this element. This method ignores inherited annotations. If there are no annotations directly present on this element, the return value is an array of length 0. The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers.Specified by: getDeclaredAnnotations in interface AnnotatedElement Returns: annotations directly present on this elementNote that any annotations returned by this method are declaration annotations.
-
toString
-
getDeclaringRecord
Returns the record class which declares this record component.Returns: The record class declaring this record component.
-
Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples. Other versions.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2026, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.