johncarl81 / parceler

:package: Android Parcelables made easy through code generation.
http://parceler.org
Apache License 2.0
3.56k stars 273 forks source link

Naming conventions for properties in class #358

Open Gloix opened 5 years ago

Gloix commented 5 years ago

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?

johncarl81 commented 5 years ago

Sorry @Gloix, I guess I missed this one from a few days ago... do you know what Java is generated from this Kotlin class?

Gloix commented 5 years ago

No worries. From Java, methods are boolean isValid(), void setID(String s) and String getID().

johncarl81 commented 5 years ago

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 ?

johncarl81 commented 5 years ago

... I should just make a KOTLIN specific strategy to handle weird issues with kotlin beans.