rharter / auto-value-gson

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

Optimize hierarchy lookups for GenerateTypeAdapter #232

Closed ZacSweers closed 4 years ago

ZacSweers commented 4 years ago

This allows for reuse of adapters as well as a faster traversal rather than the reflective fall-through. Before - it would try the whole constructor lookup before trying to walk up to the superclass as a stop-gap and also potentially create duplicate adapters in Moshi's cache.

This also revealed in testing that GenerateTypeAdapter didn't support nested types, which are fixed opportunistically here using Moshi's naming scheme.