Kartik Watwani
Kartik Watwani

Reputation: 649

Kotlin data class with Firebase getValue mapping

I have a data class in Kotlin and I have a property in the class named isFoo, note that it starts with is. Kotlin creates setters differently for fields that start with is as mentioned here due to this I am receiving an error that looks something like this

ClassMapper: No setter/field for isFoo found on class com.domain.appName.models.Settings

How can I overcome this so fields that start with is in the data class are correctly set when using the getValue function of the Realtime Database's DataSnapshot?

Upvotes: 0

Views: 278

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598797

You can add a PropertyName annotation on the field and/or accessor methods to control how it is serialized to and deserialized from the database.

Upvotes: 1

Related Questions