I am using firebase and this is my data class definition:
data class ClaimOrder(val address: String? = null,
val amount: Long = 0L,
val isProcessed: Boolean = false,
val onCreate: kotlin.Any? = ServerValue.TIMESTAMP)
however on logs I am seeing following warning: W/ClassMapper: No setter/field for isProcessed found on class com.guness.bitfarm.service.models.ClaimOrder
I have tried @SerializedName("isProcessed")
but no luck.
I can't find any official document from Firebase mentioning about the naming rules of the getter and setter, but it seems like they are looking for JavaBean-like getters/setters
When you have a property named isProcessed
, Firebase requires you to have getter/setter named getIsProcessed()
/setIsProcessed()
. However, a different naming rule is applied when the property is start with is
in Kotlin. It genarates getter/setter named isProcessed()
/setProcessed()
, according to Kotlin doc:
If the name of the property starts with
is
, a different name mapping rule is used: the name of the getter will be the same as the property name, and the name of the setter will be obtained by replacingis
withset
. For example, for a propertyisOpen
, the getter will be calledisOpen()
and the setter will be calledsetOpen()
. This rule applies for properties of any type, not justBoolean
.
I don't know the exact reason but here is my guess:
variable name isProcessed
causes different accessor methods to be generated so underlying gson
and kotlin
methods does not match.
however using just processed
seems to fix things well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With