rharter / auto-value-gson

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

Support property defaults, normalization, and validation via Builders, Take 2 #224

Closed bryanstern closed 5 years ago

bryanstern commented 5 years ago

This is a second pass at implementing a solution for #132 using the proposed AutoValue builder properties add in auto-value 1.7rc1 (see https://github.com/google/auto/issues/421). I decided to reimplement this rather than update #136 since it was so far behind master.

Unlike the original PR, Optional fields are not supported since that appears to be the direction this project has taken. See #161.

If an AutoValue class specifies a builder with the @AutoValue.Builder annotation, the generated TypeAdapter#read implementation will make use of the builder. If there is a builder factory method, it will be used. If there are multiple builder factory methods, the @AutoValueGsonBuilder will distinguish which one to use.

ZacSweers commented 5 years ago

Also CI fix worked. Ignore the gcloud build, assuming that's one of @rharter's experiments :)

rharter commented 5 years ago

Also CI fix worked. Ignore the gcloud build, assuming that's one of @rharter's experiments :)

Hmm, not sure how that ended up on this repo. Agreed, ignore that.

rharter commented 5 years ago

@zacsweers any thoughts?