Skip to content

Instantly share code, notes, and snippets.

@davidtcdeveloper
Last active May 29, 2016 18:27
Show Gist options
  • Select an option

  • Save davidtcdeveloper/efbd07084e1b026c3757f9df454e4723 to your computer and use it in GitHub Desktop.

Select an option

Save davidtcdeveloper/efbd07084e1b026c3757f9df454e4723 to your computer and use it in GitHub Desktop.
Creating adapter factory to work with GSON.
public class AutoValueTypeAdapterFactory implements TypeAdapterFactory {
@Override
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
Class<? super T> rawType = type.getRawType();
if (PersonData.class.isAssignableFrom(rawType)) {
return (TypeAdapter<T>) PersonData.typeAdapter(gson);
}
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment