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 boolean hasProfilePicure() { | |
| return this.profileUrl() != null; | |
| } |
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
| annotationProcessor 'com.ryanharter.auto.value:auto-value-parcel:0.2.2' |
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
| @AutoValue | |
| public abstract class PersonData implements Parcelable { |
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 static final Parcelable.Creator<AutoValue_PersonData> CREATOR = new Parcelable.Creator<AutoValue_PersonData>() { | |
| @Override | |
| public AutoValue_PersonData createFromParcel(Parcel in) { | |
| return new AutoValue_PersonData( | |
| in.readLong(), | |
| in.readString(), | |
| in.readInt(), | |
| in.readString(), | |
| in.readString(), | |
| in.readInt() == 0 ? in.readString() : null |
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
| annotationProcessor 'com.ryanharter.auto.value:auto-value-gson:0.3.1' | |
| compile 'com.google.code.gson:gson:2.6.2' |
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 static TypeAdapter<PersonData> typeAdapter(Gson gson) { | |
| return new AutoValue_PersonData.GsonTypeAdapter(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; | |
| } | |
| } |
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
| //... | |
| import com.ryanharter.auto.value.gson.AutoValueGsonTypeAdapterFactory; | |
| //... | |
| Gson gson = new GsonBuilder() | |
| .registerTypeAdapterFactory(new AutoValueGsonTypeAdapterFactory()) | |
| .create(); |
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
| PersonData personData = PersonData.builder() | |
| .id(1) | |
| .name("David Tiago Conceição") | |
| .eMail("david@david.com") | |
| .status(0) | |
| .profileUrl("twitter.com/davidtiagocon") | |
| .pictureImageUrl("https://pbs.twimg.com/profile_images/601894402198544384/FJupV0uC.jpg") | |
| .build(); |
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
| @GsonTypeAdapterFactory | |
| abstract class AutoValueGsonAdapterFactory implements TypeAdapterFactory { | |
| static TypeAdapterFactory create() { | |
| return new AutoValueGson_AutoValueGsonAdapterFactory(); | |
| } | |
| } |