|
28 | 28 | import com.google.gson.TypeAdapter; |
29 | 29 | import com.google.gson.TypeAdapterFactory; |
30 | 30 | import com.google.gson.internal.Streams; |
| 31 | +import com.google.gson.internal.bind.ReflectiveTypeAdapterFactory; |
31 | 32 | import com.google.gson.reflect.TypeToken; |
32 | 33 | import com.google.gson.stream.JsonReader; |
33 | 34 | import com.google.gson.stream.JsonToken; |
34 | 35 | import com.google.gson.stream.JsonWriter; |
35 | | -import com.microsoft.graph.http.BaseCollectionPage; |
36 | | -import com.microsoft.graph.http.BaseCollectionResponse; |
37 | 36 | import com.microsoft.graph.logger.ILogger; |
38 | 37 |
|
39 | 38 | import java.io.IOException; |
@@ -99,12 +98,13 @@ public <T> TypeAdapter<T> create(@Nonnull final Gson gson, @Nonnull final TypeTo |
99 | 98 | return (TypeAdapter<T>) voidAdapter; |
100 | 99 | } else if (IJsonBackedObject.class.isAssignableFrom(type.getRawType())) { |
101 | 100 |
|
| 101 | + final TypeAdapter<IJsonBackedObject> delegatedAdapter = (TypeAdapter<IJsonBackedObject>) gson.getDelegateAdapter(this, type); |
| 102 | + |
102 | 103 | // Avoid overriding custom IJsonBackedObject type adapters defined in GsonFactory |
103 | | - if (BaseCollectionResponse.class.isAssignableFrom(rawType) || BaseCollectionPage.class.isAssignableFrom(rawType)) { |
| 104 | + if (!(delegatedAdapter instanceof ReflectiveTypeAdapterFactory.Adapter)) { |
104 | 105 | return null; |
105 | 106 | } |
106 | 107 |
|
107 | | - final TypeAdapter<IJsonBackedObject> delegatedAdapter = (TypeAdapter<IJsonBackedObject>) gson.getDelegateAdapter(this, type); |
108 | 108 | return (TypeAdapter<T>) new ODataTypeParametrizedIJsonBackedObjectAdapter(gson, delegatedAdapter, (TypeToken<IJsonBackedObject>) type, logger); |
109 | 109 | } |
110 | 110 | else { |
|
0 commit comments