java.lang.Object
java.lang.reflect.RecordComponent
- All Implemented Interfaces:
- AnnotatedElement
public final class RecordComponent extends Object implements AnnotatedElement
           This class is associated with records, a preview
           feature of the Java language. Preview features
           may be removed in a future release, or upgraded to permanent
           features of the Java language.
A
RecordComponent provides information about, and dynamic access to, a
 component of a record class.- See Java Language Specification:
- 
8.10 Record Types
- Since:
- 14
- See Also:
- Class.getRecordComponents(),- Record
- 
Method SummaryModifier and Type Method Description MethodgetAccessor()Returns aMethodthat represents the accessor for this record component.AnnotatedTypegetAnnotatedType()Returns anAnnotatedTypeobject 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.Class<?>getDeclaringRecord()Returns the record class which declares this record component.StringgetGenericSignature()Returns aStringthat describes the generic type signature for this record component.TypegetGenericType()Returns aTypeobject that represents the declared type for this record component.StringgetName()Returns the name of this record component.Class<?>getType()Returns aClassthat identifies the declared type for this record component.StringtoString()Returns a string describing this record component.Methods declared in class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods declared in interface java.lang.reflect.AnnotatedElementgetAnnotations, getAnnotationsByType, getDeclaredAnnotation, getDeclaredAnnotations, getDeclaredAnnotationsByType, isAnnotationPresent
- 
Method Details- 
getNameReturns the name of this record component.- Returns:
- the name of this record component
 
- 
getTypeReturns aClassthat identifies the declared type for this record component.- Returns:
- a Classidentifying the declared type of the component represented by this record component
 
- 
getGenericSignatureReturns aStringthat describes the generic type signature for this record component.- Returns:
- a Stringthat describes the generic type signature for this record component
- See Java Virtual Machine Specification:
- 
4.7.9.1 Signatures
 
- 
getGenericTypeReturns aTypeobject that represents the declared type for this record component.If the declared type of the record component is a parameterized type, the Typeobject 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:
- a Typeobject 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 reason
 
- 
getAnnotatedTypeReturns anAnnotatedTypeobject 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
 
- 
getAccessorReturns aMethodthat represents the accessor for this record component.- Returns:
- a Methodthat represents the accessor for this record component
 
- 
getAnnotationDescription copied from interface:AnnotatedElementReturns this element's annotation for the specified type if such an annotation is present, else null.- Specified by:
- getAnnotationin 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 null
 
- 
toStringReturns 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:String name int age
- 
getDeclaringRecordReturns the record class which declares this record component.- Returns:
- The record class declaring this record component.
 
 
-