rharter / auto-value-gson

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

Allow custom opt-in annotation for factory #245

Closed ZacSweers closed 3 years ago

ZacSweers commented 4 years ago

Since we allow opting in to a factory via no parameters, we should designate something other than the autovalue annotation as an opt-in mechanism for it since a no-arg method would obviously not be using auto-value-gson-extension's generated adapter. This also allows users to use something other than auto-value, or at least use auto-value without necessarily generating the adapter.

rharter commented 4 years ago

I'm having a hard time understanding this. The idea is that user's who don't use AutoValue can opt into the having their Gson TypeAdapter's automatically picked up by the AutoValue: Gson generated type factory? That seems out of scope, and something that should be provided by another library, if not Gson itself. Is there something I'm missing?

ZacSweers commented 4 years ago

Yeah that’s the idea, with the motivation being that the factory could support this since it’s a separate artifact now. The example case I ran into for this internally was one where we had a project for all of our models and most of them use the extension but one requires it’s own custom adapter. It’s nice not to have to manually wire that custom adapter separately from the rest of the models already being wired up by the factory