I'm using Retrofit and AutoValue with the GSON extension. Everything works fine but I didn't find a way to initialize a property when the server does not return a value for it. I can add the annotation @Nullable to avoid the NPE but I'd like to be able to avoid the nulls and set a default value for the properties not set in the json.
I know how to use builders to set properties without using the gson extension but I don't know how to use these builders (or any other mean) when using the extension to set the default values.
I think you can't do this using auto-value as it is still an open issue
Reff:
http://github.com/rharter/auto-value-gson/issues/47
But the wayaround is to pass your own model to gson for parsing and in that model set the default value for any variable you want. So, when you will get the value in json response it will automatically override the default value and in other case default value is already present in the model.