johncarl81 / parceler

:package: Android Parcelables made easy through code generation.

Home Page:http://parceler.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parcel.unwrap() method returns an object with all fields filled with null when setters are not declared.

DanielGunna opened this issue · comments

Parcel.unwrap() method returns an object with all fields filled with null when a model class annotated with @Parcel(Serialization.BEAN) doesn't have setters declared. Is it possible to establish something like a warning or simply throwing this error in case I forget to declare setters methods?

Are you talking about a bean annotated with @Parcel(Serialization.BEAN) or just with @Parcel?

@Parcel(Serialization.BEAN), sorry my bad.

No problem. An error on non-matching getter/setter pairs in the BEAN configuration would match the constructor parameter / getter error that we issue. The difference with getter/setter pairs is the setter call is optional after the class construction. Technically, you can instantiate a class without the given property provided. Defining getters and setters really instructs whatever tool (in this case Parceler) how to handle your bean. If the bean has a read only property, it's not de-serializable.

Pros:
Matches constructor / getter property pair behavior
Helps avoid issues defining beans properly

Cons:
Noisy
non-matching getter/setters have a specific meaning - either they are read only or just update methods.

I don't know... I'm on the fence on this one. Thoughts?