getValue

abstract fun <T : Any> getValue(propertyName: String, clazz: KClass<T>): T

Returns the value of a specific non-nullable value property.

The class argument must be the KClass of the RealmStorageType for the property.

The following snippet outlines the different functions available for the different value types:

// Retrieve a nullable int from a 'nullableIntField' property
dynamicRealmObject.getNullableValue("nullableIntField", Int::class)

// Retrieve a non-nullable int from an 'intField' property
dynamicRealmObject.getValue("intField", Int::class)

// Retrieve an object from an `objectField' property
dynamicRealmObject.getObject("objectField", DynamicRealmObject::class)

Return

the property value.

Parameters

propertyName

the name of the property to retrieve the value for.

clazz

the Kotlin class of the value. Must match the RealmStorageType.kClass of the property in the realm.

T

the type of the value.

Throws

if the class doesn't contain a field with the specific name, if clazz doesn't match the property's RealmStorageType.kClass or if trying to retrieve collection properties.