rharter / auto-value-gson

AutoValue Extension to add Gson De/Serializer support
Apache License 2.0
607 stars 103 forks source link

Workaround for mutable adapters no longer existing #220

Closed flovouin closed 5 years ago

flovouin commented 5 years ago

Hi guys, thanks for the great package.

I'm trying to update to 1.0.0 but I'm running into issues because mutable adapters have been removed in #201. However, I'm not sure I understand how to implement my current logic differently. I have something along those lines:

@AutoValue
public abstract class MyObject {
   public abstract double getDoubleField();

    public static MyObject create(double doubleField) {
        return new AutoValue_MyObject(doubleField);
    }

    public static TypeAdapter<MyObject> typeAdapter(Gson gson) {
        return new AutoValue_MyObject.GsonTypeAdapter(gson)
                .setDefaultDoubleField(1.0);
    }
}

How can I get the same behaviour with 1.0.0? I'm a bit rusty when it comes to Gson and AutoValue, sorry if this is obvious.

Thanks,

ZacSweers commented 5 years ago

There is no workaround right now other than to not update. The ideal way to support this in the future is #132, which in turn depends on https://github.com/google/auto/pull/501.

flovouin commented 5 years ago

Thanks for the quick reply, I'll make sure to subscribe to these issues/PRs.