rharter / auto-value-gson

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

Lint Validation of addition of the typeAdapter method #45

Closed williamwebb closed 8 years ago

williamwebb commented 8 years ago

Would you/this project be interested in the addition of a aar distribution containing a lint check which validates that an AutoValue annotated class has the typeAdapter method added?

rharter commented 8 years ago

I don't think that really fits.

First of all, this isn't an Android project, it's a Java project. I'm sure you were thinking of an AAR in addition to a JAR, but I'm not sure that it makes sense just for a lint check.

Secondly, not having a typeAdapter method is completely valid. The idea is that you might not want all AutoValue annotated classes to have generated type adapters. In my cases, this is particularly useful since I use AutoValue types for local db related items in addition to objects returns from the web services, but only the remote items need type adapters.

If there's something I'm missing, I'm happy to discuss.

williamwebb commented 8 years ago

No you understood correctly.

For my information the adapter is always created regardless if the method is present or not correct?

rharter commented 8 years ago

No, you do need to include a public static method returning a TypeAdapter<Foo> that takes a Gson object. That's how the extension determines if it should generate a TypeAdapter or not. That is defined here

williamwebb commented 8 years ago

Gotcha, makes a lost more sense now :). Thanks.