MutableRealmIntKSerializer
KSerializer implementation for MutableRealmInt. Serialization is done with a primitive long value, whilst deserialization is done with an unmanaged MutableRealmInt.
The serializer must be registered per property:
class Example : RealmObject {
@Serializable(MutableRealmIntKSerializer::class)
var myMutableRealmInt: MutableRealmInt = MutableRealmInt.create(0)
}
Content copied to clipboard
or per file:
@file:UseSerializers(MutableRealmIntKSerializer::class)
class Example : RealmObject {
var myMutableRealmInt: MutableRealmInt = MutableRealmInt.create(0)
}
Content copied to clipboard
Adding the following code snippet to a Kotlin file would conveniently register any field using a Realm datatype to its correspondent serializer:
@file:UseSerializers(
RealmListKSerializer::class,
RealmSetKSerializer::class,
RealmAnyKSerializer::class,
RealmInstantKSerializer::class,
MutableRealmIntKSerializer::class,
RealmUUIDKSerializer::class
)
Content copied to clipboard
Serializers for all Realm data types can be found in io.realm.kotlin.serializers.