parceler
parceler copied to clipboard
Naming conventions for properties in class
Hi, I'm getting No corresponding property found for constructor parameter ID and No corresponding property found for constructor parameter isValid for the following Kotlin class:
@Parcel(Parcel.Serialization.BEAN)
data class MyClass @ParcelConstructor constructor(
var ID: String? = null,
val isValid: Boolean
)
I discovered that by lowercasing the ID property and removing 'is' from isValid works as expected. Is Parceler sensitive to proper naming conventions? (a.k.a. camel case properties). Why are "is" prefixed properties not valid?
Sorry @Gloix, I guess I missed this one from a few days ago... do you know what Java is generated from this Kotlin class?
No worries.
From Java, methods are boolean isValid(), void setID(String s) and String getID().
Hmm, I bet the isValid name in the constructor is colliding with the valid property name of isValid. Does it work if you change isValid to valid? Or does it work if you clarify the constructor argument with @ParcelProperty("valid") var is Valid: Boolean ?
... I should just make a KOTLIN specific strategy to handle weird issues with kotlin beans.