{% setvar book_path %}/reference/kotlin/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

ReflectiveField

class ReflectiveField<T>


Helper class for making more performant reflection field access.

Lazy initializes and caches Method object ro attempt to reduce reflection overhead.

Summary

Public constructors

ReflectiveField(className: String, fieldName: String)

Creates a ReflectiveField.

Public functions

T
get(object: Any)

Retrieves the field's value, initializing if necessary.

Public constructors

ReflectiveField

ReflectiveField(className: String, fieldName: String)

Creates a ReflectiveField.

Parameters
className: String

the fully qualified class name that defines the field

fieldName: String

the field name

Public functions

get

fun get(object: Any): T

Retrieves the field's value, initializing if necessary.

Parameters
object: Any

the object that holds the field's value

Returns
T

the field's value

Throws
androidx.test.platform.reflect.ReflectionException

if field could not be accessed