Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/java/lang/reflect/RecordComponent#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/java/lang/reflect/RecordComponent#inhmethods)

# RecordComponent

` public final class RecordComponent `   
` extends https://developer.android.com/reference/java/lang/Object ` ` implements https://developer.android.com/reference/java/lang/reflect/AnnotatedElement `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | java.lang.reflect.RecordComponent |

<br />

*** ** * ** ***

A `RecordComponent` provides information about, and dynamic access to, a component of a record class.
**See also:**

- `https://developer.android.com/reference/java/lang/Class#getRecordComponents()`
- `https://developer.android.com/reference/java/lang/Record`

## Summary

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/java/lang/reflect/Method` | ` https://developer.android.com/reference/java/lang/reflect/RecordComponent#getAccessor()() ` Returns a `Method` that represents the accessor for this record component. |
| ` <T extends https://developer.android.com/reference/java/lang/annotation/Annotation> T` | ` https://developer.android.com/reference/java/lang/reflect/RecordComponent#getAnnotation(java.lang.Class<T>)(https://developer.android.com/reference/java/lang/Class<T> annotationClass) ` 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. |
| ` https://developer.android.com/reference/java/lang/annotation/Annotation` | ` https://developer.android.com/reference/java/lang/reflect/RecordComponent#getAnnotations()() ` Returns annotations that are *present* on this element. Note that any annotations returned by this method are declaration annotations. |
| ` https://developer.android.com/reference/java/lang/annotation/Annotation` | ` https://developer.android.com/reference/java/lang/reflect/RecordComponent#getDeclaredAnnotations()() ` Returns annotations that are *directly present* on this element. Note that any annotations returned by this method are declaration annotations. |
| ` https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/reflect/RecordComponent#getDeclaringRecord()() ` Returns the record class which declares this record component. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/reflect/RecordComponent#getGenericSignature()() ` Returns a `String` that describes the generic type signature for this record component. |
| ` https://developer.android.com/reference/java/lang/reflect/Type` | ` https://developer.android.com/reference/java/lang/reflect/RecordComponent#getGenericType()() ` Returns a `Type` object that represents the declared type for this record component. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/reflect/RecordComponent#getName()() ` Returns the name of this record component. |
| ` https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/reflect/RecordComponent#getType()() ` Returns a `Class` that identifies the declared type for this record component. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/reflect/RecordComponent#toString()() ` Returns a string describing this record component. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(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.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(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 void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.
From interface ` https://developer.android.com/reference/java/lang/reflect/AnnotatedElement ` ` abstract <T extends https://developer.android.com/reference/java/lang/annotation/Annotation> T` ` https://developer.android.com/reference/java/lang/reflect/AnnotatedElement#getAnnotation(java.lang.Class<T>)(https://developer.android.com/reference/java/lang/Class<T> annotationClass) `

Returns this element's annotation for the specified type if such an annotation is *present*, else null.
` abstract https://developer.android.com/reference/java/lang/annotation/Annotation` ` https://developer.android.com/reference/java/lang/reflect/AnnotatedElement#getAnnotations()() `

Returns annotations that are *present* on this element.
` default <T extends https://developer.android.com/reference/java/lang/annotation/Annotation> T[]` ` https://developer.android.com/reference/java/lang/reflect/AnnotatedElement#getAnnotationsByType(java.lang.Class<T>)(https://developer.android.com/reference/java/lang/Class<T> annotationClass) `

Returns annotations that are *associated* with this element.
` default <T extends https://developer.android.com/reference/java/lang/annotation/Annotation> T` ` https://developer.android.com/reference/java/lang/reflect/AnnotatedElement#getDeclaredAnnotation(java.lang.Class<T>)(https://developer.android.com/reference/java/lang/Class<T> annotationClass) `

Returns this element's annotation for the specified type if such an annotation is *directly present*, else null.
` abstract https://developer.android.com/reference/java/lang/annotation/Annotation` ` https://developer.android.com/reference/java/lang/reflect/AnnotatedElement#getDeclaredAnnotations()() `

Returns annotations that are *directly present* on this element.
` default <T extends https://developer.android.com/reference/java/lang/annotation/Annotation> T[]` ` https://developer.android.com/reference/java/lang/reflect/AnnotatedElement#getDeclaredAnnotationsByType(java.lang.Class<T>)(https://developer.android.com/reference/java/lang/Class<T> annotationClass) `

Returns this element's annotation(s) for the specified type if such annotations are either *directly present* or *indirectly present*.
` default boolean` ` https://developer.android.com/reference/java/lang/reflect/AnnotatedElement#isAnnotationPresent(java.lang.Class<?%20extends%20java.lang.annotation.Annotation>)(https://developer.android.com/reference/java/lang/Class<? extends https://developer.android.com/reference/java/lang/annotation/Annotation> annotationClass) `

Returns true if an annotation for the specified type is *present* on this element, else false.

## Public methods

### getAccessor

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Method getAccessor ()
```

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

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/reflect/Method` | a `Method` that represents the accessor for this record component <br /> |

### getAnnotation

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public T getAnnotation (Class<T> annotationClass)
```

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.

<br />

| Parameters ||
|---|---|
| `annotationClass` | `Class`: the Class object corresponding to the annotation type <br /> |

| Returns ||
|---|---|
| `T` | this element's annotation for the specified annotation type if present on this element, else null <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` |   |

### getAnnotations

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public 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.

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

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/annotation/Annotation` | annotations present on this element <br /> |

### getDeclaredAnnotations

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Annotation[] 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.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/annotation/Annotation` | annotations directly present on this element <br /> |

### getDeclaringRecord

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Class<?> getDeclaringRecord ()
```

Returns the record class which declares this record component.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/Class<?>` | The record class declaring this record component. <br /> |

### getGenericSignature

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getGenericSignature ()
```

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

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a `String` that describes the generic type signature for this record component <br /> |

### getGenericType

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/reflect/Type` | a `Type` object that represents the declared type for this record component <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/TypeNotPresentException` | if the generic type signature of the underlying record component refers to a non-existent type declaration |
| `https://developer.android.com/reference/java/lang/reflect/GenericSignatureFormatError` | if the generic record component signature does not conform to the format specified in The Java Virtual Machine Specification |
| `https://developer.android.com/reference/java/lang/reflect/MalformedParameterizedTypeException` | if the generic signature of the underlying record component refers to a parameterized type that cannot be instantiated for any reason |

### getName

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getName ()
```

Returns the name of this record component.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the name of this record component <br /> |

### getType

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Class<?> getType ()
```

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

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/Class<?>` | a `Class` identifying the declared type of the component represented by this record component <br /> |

### toString

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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:

```
   java.lang.String name
   int age
```

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string describing this record component <br /> |