Last active
May 29, 2016 18:27
-
-
Save davidtcdeveloper/efbd07084e1b026c3757f9df454e4723 to your computer and use it in GitHub Desktop.
Creating adapter factory to work with GSON.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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