rharter / auto-value-gson

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

Remove @GsonTypeAdapter support #199

Closed ZacSweers closed 5 years ago

ZacSweers commented 5 years ago

After discussion offline, @rharter and I think it's best to remove this API. It's only really useful in cases where there is no configurable source of truth to delegate to (such as in auto-value-parcel). With gson though, you have... gson! These custom adapters should be wired in to the gson instance used directly. This will also allow gson to cache them for you, vs never caching when they're used as directly instantiated adapters in generated adapters.

The one case where this could still be useful is if you wanted to have different serialization for the same type within the context of a single object's serialization. For that, we recommend just making a thin wrapper type to distinguish + adapter. Or use moshi and its qualifier annotations