-
Notifications
You must be signed in to change notification settings - Fork 25
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
Support generating external adapters #146
Conversation
README.md
Outdated
using `@Json` to define an alternate name for de/serialization. | ||
Simply include auto-value-moshi in your project and annotate your target autovalue class with Moshi's | ||
`@JsonClass` annotation. `generateAdpater` must be true, and the `generator` property value should | ||
be `"avg"`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be "autovalue", or at least "avm", right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d'oh, fixed avm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice.
This gets me wondering if there's a way for the generator
property to be inferred, like a service locator in Moshi that effectively tries to find services that can generate the adapter, in this case AVM providing a generator for classes that are @JsonClass
and @AutoValue
annotated, otherwise falling back to it's own internal generator. That is most definitely a nice-to-have that's out of this scope, though, and possible not even worth it.
Possibly! R8 does support inlining servicelocator lookups so it's something we could look at. Will file an issue |
Resolves #119
This uses moshi's native generated adapter lookup mechanism. To use, simply annotate the autovalue class with
@JsonClass(generateAdapter = true, generator = "avg")
and then auto-value-moshi will generate a top-level adapter.