APIdia Launch Partner
Top Description Fields Constructors Methods
java.lang.reflect

public final Class RecordComponent

extends Object
implements AnnotatedElement
Class Inheritance
All Implemented Interfaces
java.lang.reflect.AnnotatedElement
Imports
jdk.internal.access.SharedSecrets, sun.reflect.annotation.AnnotationParser, .TypeAnnotation, .TypeAnnotationParser, sun.reflect.generics.factory.CoreReflectionFactory, .GenericsFactory, sun.reflect.generics.repository.FieldRepository, sun.reflect.generics.scope.ClassScope, java.lang.annotation.Annotation, java.util.Map, .Objects

A RecordComponent provides information about, and dynamic access to, a component of a record class.
Since
16
Java Language Specification
8.10 Record Classes
See Also
Class#getRecordComponents(), java.lang.Record

Field Summary

Modifier and TypeField and Description
private Method
private byte[]
private Class<?>
private transient volatile Map<Class<? extends Annotation>, Annotation>
private transient volatile FieldRepository
private String
private RecordComponent
private String
private Class<?>
private byte[]

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private Map<Class<? extends Annotation>, Annotation>
public Method

Returns:

a Method that represents the accessor for this record component
getAccessor
()

Returns a Method that represents the accessor for this record component.

public AnnotatedType

Returns:

an object representing the declared type of this record component
getAnnotatedType
()

Returns an AnnotatedType object that represents the use of a type to specify the declared type of this record component.

public <T extends Annotation> T
getAnnotation(Class<T> annotationClass)

Implements java.lang.reflect.AnnotatedElement.getAnnotation.

Returns this element's annotation for the specified type if such an annotation is present, else null.

public Annotation[]
getAnnotations()

Implements java.lang.reflect.AnnotatedElement.getAnnotations.

Returns annotations that are present on this element.

public Annotation[]
getDeclaredAnnotations()

Implements java.lang.reflect.AnnotatedElement.getDeclaredAnnotations.

Returns annotations that are directly present on this element.

public Class<?>

Returns:

The record class declaring this record component.
getDeclaringRecord
()

Returns the record class which declares this record component.

private GenericsFactory
private FieldRepository
public String

Returns:

a String that describes the generic type signature for this record component
getGenericSignature
()

Returns a String that describes the generic type signature for this record component.

public Type

Returns:

a Type object that represents the declared type for this record component
getGenericType
()

Returns a Type object that represents the declared type for this record component.

public String

Returns:

the name of this record component
getName
()

Returns the name of this record component.

public Class<?>

Returns:

a Class identifying the declared type of the component represented by this record component
getType
()

Returns a Class that identifies the declared type for this record component.

public String

Returns:

a string describing this record component
toString
()

Overrides java.lang.Object.toString.

Returns a string describing this record component.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

accessorback to summary
private Method accessor
annotationsback to summary
private byte[] annotations
clazzback to summary
private Class<?> clazz
declaredAnnotationsback to summary
private transient volatile Map<Class<? extends Annotation>, Annotation> declaredAnnotations
genericInfoback to summary
private transient volatile FieldRepository genericInfo
nameback to summary
private String name
rootback to summary
private RecordComponent root
signatureback to summary
private String signature
typeback to summary
private Class<?> type
typeAnnotationsback to summary
private byte[] typeAnnotations

Constructor Detail

RecordComponentback to summary
private RecordComponent()

Method Detail

declaredAnnotationsback to summary
private Map<Class<? extends Annotation>, Annotation> declaredAnnotations()
getAccessorback to summary
public Method getAccessor()

Returns a Method that represents the accessor for this record component.

Returns:Method

a Method that represents the accessor for this record component

getAnnotatedTypeback to summary
public AnnotatedType getAnnotatedType()

Returns an AnnotatedType object that represents the use of a type to specify the declared type of this record component.

Returns:AnnotatedType

an object representing the declared type of this record component

getAnnotationback to summary
public <T extends Annotation> T getAnnotation(Class<T> annotationClass)

Implements java.lang.reflect.AnnotatedElement.getAnnotation.

Doc from java.lang.reflect.AnnotatedElement.getAnnotation.

Returns this element's annotation for the specified type if such an annotation is present, else null.

Note that any annotation returned by this method is a declaration annotation.

Annotations
@Override
Exceptions
NullPointerException:
if the given annotation class is null
getAnnotationsback to summary
public Annotation[] getAnnotations()

Implements java.lang.reflect.AnnotatedElement.getAnnotations.

Doc from java.lang.reflect.AnnotatedElement.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.

Note that any annotations returned by this method are declaration annotations.

Annotations
@Override
getDeclaredAnnotationsback to summary
public Annotation[] getDeclaredAnnotations()

Implements java.lang.reflect.AnnotatedElement.getDeclaredAnnotations.

Doc from java.lang.reflect.AnnotatedElement.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.

Note that any annotations returned by this method are declaration annotations.

Annotations
@Override
getDeclaringRecordback to summary
public Class<?> getDeclaringRecord()

Returns the record class which declares this record component.

Returns:Class<?>

The record class declaring this record component.

getFactoryback to summary
private GenericsFactory getFactory()
getGenericInfoback to summary
private FieldRepository getGenericInfo()
getGenericSignatureback to summary
public String getGenericSignature()

Returns a String that describes the generic type signature for this record component.

Returns:String

a String that describes the generic type signature for this record component

Java Virtual Machine Specification
4.7.9.1 Signatures
getGenericTypeback to summary
public Type getGenericType()

Returns a Type object that represents the declared type for this record component.

If 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.

Returns:Type

a Type object that represents the declared type for this record component

Exceptions
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 reason
getNameback to summary
public String getName()

Returns the name of this record component.

Returns:String

the name of this record component

getTypeback to summary
public Class<?> getType()

Returns a Class that identifies the declared type for this record component.

Returns:Class<?>

a Class identifying the declared type of the component represented by this record component

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string describing this record component. The format is the record component type, followed by a space, followed by the name of the record component. For example:

   java.lang.String name
   int age
Returns:String

a string describing this record component