From ff418a3b524267887215f4ea59c1a040b2c4f9b1 Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 8 Dec 2016 11:44:06 +0530 Subject: [PATCH 001/159] Sample app changes --- .../vimeo/sample/model/AbstractDataList.java | 6 ++++-- .../vimeo/sample/model/AccessModifiers.java | 10 ++++++---- .../com/vimeo/sample/model/ConcreteClass.java | 9 +++++---- .../com/vimeo/sample/model/GenericClass.java | 9 +++++---- .../sample/model/IdenticalFieldTypes.java | 18 +++++++++-------- .../com/vimeo/sample/model/NestedModel.java | 6 ++++-- .../java/com/vimeo/sample/model/Paging.java | 6 ++++-- .../vimeo/sample/model/RecursiveClass.java | 20 ++++++++++--------- .../java/com/vimeo/sample/model/Stats.java | 6 ++++-- .../sample/model/SuperAbstractDataList.java | 8 +++++--- .../sample/model/TypeTokenBasedModels.java | 8 +++++--- .../java/com/vimeo/sample/model/User.java | 8 +++++--- .../java/com/vimeo/sample/model/Video.java | 16 +++++++-------- .../com/vimeo/sample/model/VideoList.java | 4 ++-- 14 files changed, 78 insertions(+), 56 deletions(-) diff --git a/sample/src/main/java/com/vimeo/sample/model/AbstractDataList.java b/sample/src/main/java/com/vimeo/sample/model/AbstractDataList.java index 1a2a42c4..bfff20b0 100644 --- a/sample/src/main/java/com/vimeo/sample/model/AbstractDataList.java +++ b/sample/src/main/java/com/vimeo/sample/model/AbstractDataList.java @@ -23,7 +23,8 @@ */ package com.vimeo.sample.model; -import com.vimeo.stag.GsonAdapterKey; +import com.google.gson.annotations.SerializedName; +import com.vimeo.stag.UseStag; import java.util.ArrayList; @@ -35,9 +36,10 @@ * * @param the type of the list. */ +@UseStag public abstract class AbstractDataList extends SuperAbstractDataList> { - @GsonAdapterKey + @SerializedName("page") public int page; } diff --git a/sample/src/main/java/com/vimeo/sample/model/AccessModifiers.java b/sample/src/main/java/com/vimeo/sample/model/AccessModifiers.java index 66746521..6c2d840a 100644 --- a/sample/src/main/java/com/vimeo/sample/model/AccessModifiers.java +++ b/sample/src/main/java/com/vimeo/sample/model/AccessModifiers.java @@ -23,24 +23,26 @@ */ package com.vimeo.sample.model; -import com.vimeo.stag.GsonAdapterKey; +import com.google.gson.annotations.SerializedName; +import com.vimeo.stag.UseStag; /** * Entity ensuring that all supported modifiers are allowed. * Public, protected, and package-private modifiers are allowed. * Private modifier is not allowed. */ +@UseStag public class AccessModifiers { // private modifier is not allowed - @GsonAdapterKey + @SerializedName("defaultModifier") String defaultModifier; - @GsonAdapterKey + @SerializedName("protectedModifier") protected String protectedModifier; - @GsonAdapterKey + @SerializedName("publicModifier") public String publicModifier; } diff --git a/sample/src/main/java/com/vimeo/sample/model/ConcreteClass.java b/sample/src/main/java/com/vimeo/sample/model/ConcreteClass.java index 5066c43c..f97f841f 100644 --- a/sample/src/main/java/com/vimeo/sample/model/ConcreteClass.java +++ b/sample/src/main/java/com/vimeo/sample/model/ConcreteClass.java @@ -23,7 +23,8 @@ */ package com.vimeo.sample.model; -import com.vimeo.stag.GsonAdapterKey; +import com.google.gson.annotations.SerializedName; +import com.vimeo.stag.UseStag; /** * This class provides an example of using @@ -31,17 +32,17 @@ */ public class ConcreteClass { - @GsonAdapterKey + @SerializedName("doublyNestedModel") NestedModel.DoublyNestedModel doublyNestedModel; public static class NestedModel { - @GsonAdapterKey + @SerializedName("message") public String message; public static class DoublyNestedModel { - @GsonAdapterKey + @SerializedName("message") public String message; } } diff --git a/sample/src/main/java/com/vimeo/sample/model/GenericClass.java b/sample/src/main/java/com/vimeo/sample/model/GenericClass.java index f772d3a1..8a55d962 100644 --- a/sample/src/main/java/com/vimeo/sample/model/GenericClass.java +++ b/sample/src/main/java/com/vimeo/sample/model/GenericClass.java @@ -1,18 +1,19 @@ package com.vimeo.sample.model; -import com.vimeo.stag.GsonAdapterKey; +import com.google.gson.annotations.SerializedName; +import com.vimeo.stag.UseStag; import java.util.Map; /** * Created by anirudh.r on 30/11/16. */ - +@UseStag public class GenericClass { - @GsonAdapterKey + @SerializedName("name") public T name; - @GsonAdapterKey + @SerializedName("map") public Map> mapField; } \ No newline at end of file diff --git a/sample/src/main/java/com/vimeo/sample/model/IdenticalFieldTypes.java b/sample/src/main/java/com/vimeo/sample/model/IdenticalFieldTypes.java index 421f57e8..e51ba010 100644 --- a/sample/src/main/java/com/vimeo/sample/model/IdenticalFieldTypes.java +++ b/sample/src/main/java/com/vimeo/sample/model/IdenticalFieldTypes.java @@ -23,7 +23,8 @@ */ package com.vimeo.sample.model; -import com.vimeo.stag.GsonAdapterKey; +import com.google.gson.annotations.SerializedName; +import com.vimeo.stag.UseStag; import java.util.ArrayList; import java.util.List; @@ -37,26 +38,27 @@ * generated for the same type within the * type adapter factory. */ +@UseStag public class IdenticalFieldTypes { - @GsonAdapterKey + @SerializedName("mUser") User mUser; - @GsonAdapterKey + @SerializedName("mSecondUser") User mSecondUser; - @GsonAdapterKey + @SerializedName("mUsersList") ArrayList mUsersList; - @GsonAdapterKey + @SerializedName("mSecondUsersList") ArrayList mSecondUsersList; - @GsonAdapterKey + @SerializedName("mStatsArrayList") ArrayList mStatsArrayList; - @GsonAdapterKey("mListOfList") + @SerializedName("mListOfList") List> mListOfList; - @GsonAdapterKey("mStats") + @SerializedName("mStats") Stats mStats; } diff --git a/sample/src/main/java/com/vimeo/sample/model/NestedModel.java b/sample/src/main/java/com/vimeo/sample/model/NestedModel.java index e9f0a76e..b90e88dd 100644 --- a/sample/src/main/java/com/vimeo/sample/model/NestedModel.java +++ b/sample/src/main/java/com/vimeo/sample/model/NestedModel.java @@ -23,15 +23,17 @@ */ package com.vimeo.sample.model; -import com.vimeo.stag.GsonAdapterKey; +import com.google.gson.annotations.SerializedName; +import com.vimeo.stag.UseStag; /** * This class simulates a scenario where a class with the same * name is also present as a static inner class of another class * in the same package, see {@link ConcreteClass.NestedModel}. */ +@UseStag public class NestedModel { - @GsonAdapterKey + @SerializedName("test1") public String test1; } diff --git a/sample/src/main/java/com/vimeo/sample/model/Paging.java b/sample/src/main/java/com/vimeo/sample/model/Paging.java index 1590867c..77726060 100644 --- a/sample/src/main/java/com/vimeo/sample/model/Paging.java +++ b/sample/src/main/java/com/vimeo/sample/model/Paging.java @@ -23,14 +23,16 @@ */ package com.vimeo.sample.model; -import com.vimeo.stag.GsonAdapterKey; +import com.google.gson.annotations.SerializedName; +import com.vimeo.stag.UseStag; /** * Simple paging info model used by the sample. */ +@UseStag public class Paging { - @GsonAdapterKey + @SerializedName("first") public String first; } diff --git a/sample/src/main/java/com/vimeo/sample/model/RecursiveClass.java b/sample/src/main/java/com/vimeo/sample/model/RecursiveClass.java index 9fca64d8..503306bc 100644 --- a/sample/src/main/java/com/vimeo/sample/model/RecursiveClass.java +++ b/sample/src/main/java/com/vimeo/sample/model/RecursiveClass.java @@ -1,7 +1,8 @@ package com.vimeo.sample.model; -import com.vimeo.stag.GsonAdapterKey; +import com.google.gson.annotations.SerializedName; +import com.vimeo.stag.UseStag; import java.util.Collection; import java.util.List; @@ -11,25 +12,26 @@ * This can be inside the same class or could be in a class referenced by * this class which again refers back to this class */ +@UseStag public class RecursiveClass { - @GsonAdapterKey + @SerializedName("checkSum") public String checkSum; - @GsonAdapterKey + @SerializedName("stringNativeArray") public String[] stringNativeArray; - @GsonAdapterKey + @SerializedName("integerObject") public Integer integerObject; - @GsonAdapterKey + @SerializedName("integerArray") public List integerArray; - @GsonAdapterKey + @SerializedName("collection") public Collection collection; - @GsonAdapterKey + @SerializedName("nativeIntegerArray") public int[] nativeIntegerArray; - @GsonAdapterKey + @SerializedName("innerSum") public RecursiveClass innerSum; -} +} \ No newline at end of file diff --git a/sample/src/main/java/com/vimeo/sample/model/Stats.java b/sample/src/main/java/com/vimeo/sample/model/Stats.java index 52211fe6..19bbcfef 100644 --- a/sample/src/main/java/com/vimeo/sample/model/Stats.java +++ b/sample/src/main/java/com/vimeo/sample/model/Stats.java @@ -23,14 +23,16 @@ */ package com.vimeo.sample.model; -import com.vimeo.stag.GsonAdapterKey; +import com.google.gson.annotations.SerializedName; +import com.vimeo.stag.UseStag; /** * Simple stats model used by the sample app. */ +@UseStag public class Stats { - @GsonAdapterKey("plays") + @SerializedName("plays") public int mPlays; diff --git a/sample/src/main/java/com/vimeo/sample/model/SuperAbstractDataList.java b/sample/src/main/java/com/vimeo/sample/model/SuperAbstractDataList.java index ba9cb431..c35147ad 100644 --- a/sample/src/main/java/com/vimeo/sample/model/SuperAbstractDataList.java +++ b/sample/src/main/java/com/vimeo/sample/model/SuperAbstractDataList.java @@ -23,7 +23,8 @@ */ package com.vimeo.sample.model; -import com.vimeo.stag.GsonAdapterKey; +import com.google.gson.annotations.SerializedName; +import com.vimeo.stag.UseStag; /** * Ensures that retrieving fields from @@ -35,12 +36,13 @@ * @param the paging type. * @param the data type. */ +@UseStag public abstract class SuperAbstractDataList { - @GsonAdapterKey + @SerializedName("paging") public T paging; - @GsonAdapterKey + @SerializedName("data") public K data; } diff --git a/sample/src/main/java/com/vimeo/sample/model/TypeTokenBasedModels.java b/sample/src/main/java/com/vimeo/sample/model/TypeTokenBasedModels.java index 2ac1e4f7..793f8d5b 100644 --- a/sample/src/main/java/com/vimeo/sample/model/TypeTokenBasedModels.java +++ b/sample/src/main/java/com/vimeo/sample/model/TypeTokenBasedModels.java @@ -23,7 +23,8 @@ */ package com.vimeo.sample.model; -import com.vimeo.stag.GsonAdapterKey; +import com.google.gson.annotations.SerializedName; +import com.vimeo.stag.UseStag; import java.util.List; import java.util.Map; @@ -34,11 +35,12 @@ * the interface fields for Map and List, * according to what stag supports. */ +@UseStag public class TypeTokenBasedModels { - @GsonAdapterKey("videoMap") + @SerializedName("videoMap") public Map videoMap; - @GsonAdapterKey("videoList") + @SerializedName("videoList") public List