kotlinrealmnullablerealm-java

Realm: How to tell if a field is nullable via DynamicRealm?


Does DynamicRealm offer a way to determine if a field is nullable on a kotlin RealmModel subclass?

For example, given the following realm models:

open class IntObj(
    var i: Int = 1
): RealmObject()
open class NullIntObj(
    var i: Int? = null
): RealmObject()

If I fetch a dynamic realm object representation of each type and try to determine the field type of parameter "i" via dynamicRealmObj.getFieldType("i"), they both return "INTEGER".

Is there a way I can determine the nullability of a field on a dynamic realm object? Do I have to use reflection to try and determine what the underlying Java field is annotated with?


Solution

  • Well I'm an idiot - turns out dynamicRealm.isNullable(fieldName) totally exists :)