Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Parceler, use getters and setters #38

Closed
johnjohndoe opened this issue Feb 17, 2015 · 14 comments
Closed

Support for Parceler, use getters and setters #38

johnjohndoe opened this issue Feb 17, 2015 · 14 comments

Comments

@johnjohndoe
Copy link

I use POJOs with Jackson annotations and Parceler for my client model. Such a class looks like this:

@Parcel
public class Properties {

    @JsonProperty("product")
    private String product;

    @JsonProperty("product")
    public String getProduct() {
        return product;
    }

    @JsonProperty("product")
    public void setProduct(String product) {
        this.product = product;
    }

}

When I let Icepick handle the instance state the following error occurs:

Parceler: Reflection is required to modify private field: String product, consider using non-private.

Do you know why this is happening?

@frankiesardo
Copy link
Owner

Which version of icepick are you using?

@johnjohndoe
Copy link
Author

3.0.0 via clojars.org

@frankiesardo
Copy link
Owner

I'm assuming if you don't use icepick and do the calls to Bundle manually with the same POJO you don't get any error, right?

Can you post the code invocation that fails?

@johnjohndoe
Copy link
Author

Correct. Without Icepick I do:

outState.putParcelable(BundleKeys.SELECTED_PROPERTIES, Parcels.wrap(mProperties));

and

Parcelable parcelable = savedInstanceState.getParcelable(BundleKeys.SELECTED_PROPERTIES);
mProperties = Parcels.unwrap(parcelable);

@frankiesardo
Copy link
Owner

And how do you do with icepick?
@Icicle Properties mProperties should fail to compile because Properties does not implement Parcelable

@johnjohndoe
Copy link
Author

True. It feels as if Icepick and Parceler have to get married. It would probably work if I could pass a Parcelable to Icepick ...

public static <T> android.os.Parcelable saveInstanceState(T t, android.os.Parcelable parcelable)

... such as here:

Icepick.saveInstanceState(this, Parcels.wrap(mProperties));

But then I still could not use the @Icicle annotation. Something magic like @Icicle(use=Parceler) would be nice.

@frankiesardo
Copy link
Owner

Here's the discussion relative to Parceler and why I support AutoParcel as a better alternative. #20

If you use AutoParcel Icepick will work out of the box. I think you could use the new AutoValue Builder feature for Jackson/Gson support.

BTW did your code fail to compile as I said? If not please let me know because that would be an icepick bug.

@johnjohndoe
Copy link
Author

No unforeseen error. After I removed the private qualifier for the @Icicle annotated member the following error occurs for good reasons:

Error: Don't know how to put a com.example.Product inside a Bundle

@frankiesardo
Copy link
Owner

Cool. If you're willing to try out AutoParcel and need help in setting it up let me know.

@johnjohndoe
Copy link
Author

Thank you for pointing me at #20 - I just read through the issue. I do not have time to integrate AutoParcel right now but I put it on my TODO list. Thank you for your time.

@johncarl81
Copy link

@johnjohndoe FYI, I have a fork of Icepick that works as you describe with Parceler here: https://github.com/johncarl81/icepick/tree/parceler_support. Looks like I need to rebase onto the newest clojure branch.

@frankiesardo
Copy link
Owner

@johncarl81 version 3.0.0 fixes some bugs, but the previous version you're based on should still be usable. You could use this as a great opportunity to step up your Clojure game! Ping me if you have any questions

@johncarl81
Copy link

@frankiesardo that's what I was thinking. Will do, Thanks!

@johnjohndoe
Copy link
Author

@johncarl81 Thanks for the note.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants