

RecordComponent (Java SE 15 & JDK 15)
source link: https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/lang/reflect/RecordComponent.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Method Details
-
getName
public String getName()Returns the name of this record component.Returns: the name of this record component -
getType
public Class<?> getType()Returns aReturns: aClass
that identifies the declared type for this record component.Class
identifying the declared type of the component represented by this record component -
getGenericSignature
public String getGenericSignature()Returns aString
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: -
getGenericType
public Type getGenericType()Returns: aReturns 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.
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 SpecificationTypeNotPresentException
- if the generic type signature of the underlying record component refers to a non-existent type declarationMalformedParameterizedTypeException
- if the generic signature of the underlying record component refers to a parameterized type that cannot be instantiated for any reason -
getAnnotatedType
public AnnotatedType getAnnotatedType()Returns anReturns: an object representing the declared type of this record componentAnnotatedType
object that represents the use of a type to specify the declared type of this record component. -
getAccessor
public Method getAccessor()Returns aReturns: aMethod
that represents the accessor for this record component.Method
that represents the accessor for this record component -
getAnnotation
public <T extends Annotation> T getAnnotation(Class<T> annotationClass)Returns this element's annotation for the specified type if such an annotation is present, else null.Specified by:Note that any annotation returned by this method is a declaration annotation.
getAnnotation
in interfaceAnnotatedElement
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 -
getAnnotations
public Annotation[] getAnnotations()Specified by: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.
getAnnotations
in interfaceAnnotatedElement
Returns: annotations present on this element -
getDeclaredAnnotations
public Annotation[] getDeclaredAnnotations()Specified by: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.
getDeclaredAnnotations
in interfaceAnnotatedElement
Returns: annotations directly present on this element -
toString
public String 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:Overrides:java.lang.String name int age
toString
in classObject
Returns: a string describing this record component -
getDeclaringRecord
public Class<?> getDeclaringRecord()Returns the record class which declares this record component.Returns: The record class declaring this record component.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK