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

Lint Validation of addition of the typeAdapter method #45

Closed
williamwebb opened this issue May 25, 2016 · 4 comments
Closed

Lint Validation of addition of the typeAdapter method #45

williamwebb opened this issue May 25, 2016 · 4 comments

Comments

@williamwebb
Copy link

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
Copy link
Owner

rharter commented May 25, 2016

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
Copy link
Author

No you understood correctly.

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

@rharter
Copy link
Owner

rharter commented May 25, 2016

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
Copy link
Author

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

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

2 participants