Ejemplo n.º 1
0
 public <T> TypeAdapter<T> getDelegateAdapter(
     TypeAdapterFactory typeAdapterFactory, TypeToken<T> typeToken) {
   Object obj = null;
   for (TypeAdapterFactory typeAdapterFactory2 : this.factories) {
     if (obj != null) {
       TypeAdapter<T> create = typeAdapterFactory2.create(this, typeToken);
       if (create != null) {
         return create;
       }
     } else if (typeAdapterFactory2 == typeAdapterFactory) {
       obj = 1;
     }
   }
   throw new IllegalArgumentException("GSON cannot serialize " + typeToken);
 }
Ejemplo n.º 2
0
 public <T> TypeAdapter<T> getAdapter(TypeToken<T> typeToken) {
   TypeAdapter<T> typeAdapter = (TypeAdapter) this.typeTokenCache.get(typeToken);
   if (typeAdapter == null) {
     Map map;
     Map map2 = (Map) this.calls.get();
     Object obj = null;
     if (map2 == null) {
       HashMap hashMap = new HashMap();
       this.calls.set(hashMap);
       map = hashMap;
       obj = 1;
     } else {
       map = map2;
     }
     FutureTypeAdapter futureTypeAdapter = (FutureTypeAdapter) map.get(typeToken);
     if (futureTypeAdapter == null) {
       try {
         FutureTypeAdapter futureTypeAdapter2 = new FutureTypeAdapter();
         map.put(typeToken, futureTypeAdapter2);
         for (TypeAdapterFactory create : this.factories) {
           typeAdapter = create.create(this, typeToken);
           if (typeAdapter != null) {
             futureTypeAdapter2.setDelegate(typeAdapter);
             this.typeTokenCache.put(typeToken, typeAdapter);
             map.remove(typeToken);
             if (obj != null) {
               this.calls.remove();
             }
           }
         }
         throw new IllegalArgumentException("GSON cannot handle " + typeToken);
       } catch (Throwable th) {
         map.remove(typeToken);
         if (obj != null) {
           this.calls.remove();
         }
       }
     }
   }
   return typeAdapter;
 }