Java 类com.google.gson.TypeAdapterFactory 实例源码

项目:odoo-work    文件:JsonAdapterAnnotationTypeAdapterFactory.java   
@SuppressWarnings("unchecked") // Casts guarded by conditionals.
static TypeAdapter<?> getTypeAdapter(ConstructorConstructor constructorConstructor, Gson gson,
    TypeToken<?> fieldType, JsonAdapter annotation) {
  Class<?> value = annotation.value();
  if (TypeAdapter.class.isAssignableFrom(value)) {
        Class<TypeAdapter<?>> typeAdapter = (Class<TypeAdapter<?>>) value;
    return constructorConstructor.get(TypeToken.get(typeAdapter)).construct();
  }
  if (TypeAdapterFactory.class.isAssignableFrom(value)) {
        Class<TypeAdapterFactory> typeAdapterFactory = (Class<TypeAdapterFactory>) value;
    return constructorConstructor.get(TypeToken.get(typeAdapterFactory))
        .construct()
        .create(gson, fieldType);
  }

  throw new IllegalArgumentException(
      "@JsonAdapter value must be TypeAdapter or TypeAdapterFactory reference.");
}
项目:Java--Steam-Loader    文件:SteamGson.java   
public static Gson buildGson() {

        final GsonBuilder gson = new GsonBuilder();

        //gson.setPrettyPrinting();
        gson.serializeNulls();
        gson.excludeFieldsWithModifiers(Modifier.STATIC, Modifier.TRANSIENT, Modifier.VOLATILE);

        // register the type adapter factories
        final TypeAdapterFactoryCreator creator = new TypeAdapterFactoryCreator();
        for (final TypeAdapterFactory factory : creator.getAdapters()) {
            gson.registerTypeAdapterFactory(factory);
        }

        return gson.create();
    }
项目:odoo-follow-up    文件:JsonAdapterAnnotationTypeAdapterFactory.java   
@SuppressWarnings("unchecked") // Casts guarded by conditionals.
static TypeAdapter<?> getTypeAdapter(ConstructorConstructor constructorConstructor, Gson gson,
    TypeToken<?> fieldType, JsonAdapter annotation) {
  Class<?> value = annotation.value();
  if (TypeAdapter.class.isAssignableFrom(value)) {
        Class<TypeAdapter<?>> typeAdapter = (Class<TypeAdapter<?>>) value;
    return constructorConstructor.get(TypeToken.get(typeAdapter)).construct();
  }
  if (TypeAdapterFactory.class.isAssignableFrom(value)) {
        Class<TypeAdapterFactory> typeAdapterFactory = (Class<TypeAdapterFactory>) value;
    return constructorConstructor.get(TypeToken.get(typeAdapterFactory))
        .construct()
        .create(gson, fieldType);
  }

  throw new IllegalArgumentException(
      "@JsonAdapter value must be TypeAdapter or TypeAdapterFactory reference.");
}
项目:MyJojoXUtils    文件:JsonAdapterAnnotationTypeAdapterFactory.java   
@SuppressWarnings("unchecked") // Casts guarded by conditionals.
static TypeAdapter<?> getTypeAdapter(ConstructorConstructor constructorConstructor, Gson gson,
    TypeToken<?> fieldType, JsonAdapter annotation) {
  Class<?> value = annotation.value();
  TypeAdapter<?> typeAdapter;
  if (TypeAdapter.class.isAssignableFrom(value)) {
    Class<TypeAdapter<?>> typeAdapterClass = (Class<TypeAdapter<?>>) value;
    typeAdapter = constructorConstructor.get(TypeToken.get(typeAdapterClass)).construct();
  } else if (TypeAdapterFactory.class.isAssignableFrom(value)) {
    Class<TypeAdapterFactory> typeAdapterFactory = (Class<TypeAdapterFactory>) value;
    typeAdapter = constructorConstructor.get(TypeToken.get(typeAdapterFactory))
        .construct()
        .create(gson, fieldType);
  } else {
    throw new IllegalArgumentException(
        "@JsonAdapter value must be TypeAdapter or TypeAdapterFactory reference.");
  }
  if (typeAdapter != null) {
    typeAdapter = typeAdapter.nullSafe();
  }
  return typeAdapter;
}
项目:MyJojoXUtils    文件:JSONUtils.java   
protected static GsonBuilder generateBuilder() {
    GsonBuilder builder = new GsonBuilder();

    synchronized (typeAdapters) {
        for (Entry<Class<?>, Object> adapter : typeAdapters.entrySet()) {
            builder.registerTypeAdapter(adapter.getKey(), adapter.getValue());
        }
    }
    synchronized (typeAdapterFactories) {
        for (TypeAdapterFactory factory : typeAdapterFactories) {
            builder.registerTypeAdapterFactory(factory);
        }
    }

    return builder;
}
项目:FMTech    文件:TypeAdapters.java   
public static <TT> TypeAdapterFactory newFactory(Class<TT> paramClass, final TypeAdapter<TT> paramTypeAdapter)
{
  new TypeAdapterFactory()
  {
    public final <T> TypeAdapter<T> create(Gson paramAnonymousGson, TypeToken<T> paramAnonymousTypeToken)
    {
      if (paramAnonymousTypeToken.rawType == this.val$type) {
        return paramTypeAdapter;
      }
      return null;
    }

    public final String toString()
    {
      return "Factory[type=" + this.val$type.getName() + ",adapter=" + paramTypeAdapter + "]";
    }
  };
}
项目:FMTech    文件:TypeAdapters.java   
public static <TT> TypeAdapterFactory newFactory(Class<TT> paramClass1, final Class<TT> paramClass2, final TypeAdapter<? super TT> paramTypeAdapter)
{
  new TypeAdapterFactory()
  {
    public final <T> TypeAdapter<T> create(Gson paramAnonymousGson, TypeToken<T> paramAnonymousTypeToken)
    {
      Class localClass = paramAnonymousTypeToken.rawType;
      if ((localClass == this.val$unboxed) || (localClass == paramClass2)) {
        return paramTypeAdapter;
      }
      return null;
    }

    public final String toString()
    {
      return "Factory[type=" + paramClass2.getName() + "+" + this.val$unboxed.getName() + ",adapter=" + paramTypeAdapter + "]";
    }
  };
}
项目:StaticMC    文件:JsonAdapterAnnotationTypeAdapterFactory.java   
@SuppressWarnings("unchecked") // Casts guarded by conditionals.
static TypeAdapter<?> getTypeAdapter(ConstructorConstructor constructorConstructor, Gson gson,
    TypeToken<?> fieldType, JsonAdapter annotation) {
  Class<?> value = annotation.value();
  if (TypeAdapter.class.isAssignableFrom(value)) {
        Class<TypeAdapter<?>> typeAdapter = (Class<TypeAdapter<?>>) value;
    return constructorConstructor.get(TypeToken.get(typeAdapter)).construct();
  }
  if (TypeAdapterFactory.class.isAssignableFrom(value)) {
        Class<TypeAdapterFactory> typeAdapterFactory = (Class<TypeAdapterFactory>) value;
    return constructorConstructor.get(TypeToken.get(typeAdapterFactory))
        .construct()
        .create(gson, fieldType);
  }

  throw new IllegalArgumentException(
      "@JsonAdapter value must be TypeAdapter or TypeAdapterFactory reference.");
}
项目:funf-v4    文件:DefaultRuntimeTypeAdapterFactory.java   
/**
 * @param context
 * @param baseClass  
 * @param defaultClass  Setting this to null will cause a ParseException if the runtime type information is incorrect or unavailable.
 */
public DefaultRuntimeTypeAdapterFactory(Context context, Class<E> baseClass, Class<? extends E> defaultClass, TypeAdapterFactory delegateFactory) {
    assert context != null && baseClass != null;
    if (defaultClass != null && !isInstantiable(defaultClass)) {
        throw new RuntimeException("Default class does not have a default contructor.");
    }
    this.context = context;
    this.baseClass = baseClass;
    this.defaultClass = defaultClass;
    if (delegateFactory == null) {
        this.delegateFactory = new ReflectiveTypeAdapterFactory(
                new ConstructorConstructor(Collections.<Type, InstanceCreator<?>>emptyMap()), 
                FieldNamingPolicy.IDENTITY, 
                Excluder.DEFAULT);
    } else {
        this.delegateFactory = delegateFactory;
    }
}
项目:GitHub    文件:RepositorySetup.java   
private static Gson createGson() {
  GsonBuilder gsonBuilder = new GsonBuilder();
  for (TypeAdapterFactory factory : ServiceLoader.load(TypeAdapterFactory.class)) {
    gsonBuilder.registerTypeAdapterFactory(factory);
  }
  return gsonBuilder.create();
}
项目:GitHub    文件:ManualStorage.java   
private static Gson createGson() {
  GsonBuilder gsonBuilder = new GsonBuilder();
  for (TypeAdapterFactory factory : ServiceLoader.load(TypeAdapterFactory.class)) {
    gsonBuilder.registerTypeAdapterFactory(factory);
  }
  return gsonBuilder.create();
}
项目:GitHub    文件:GsonMessageBodyProvider.java   
/**
 * the fully configured gson instance.
 * @return the gson instanse
 */
@Value.Default
public Gson gson() {
  GsonBuilder gsonBuilder = new GsonBuilder();
  for (TypeAdapterFactory factory : ServiceLoader.load(TypeAdapterFactory.class)) {
    gsonBuilder.registerTypeAdapterFactory(factory);
  }
  return gsonBuilder.create();
}
项目:ProjectAres    文件:SerializationManifest.java   
@Provides
GsonBuilder gsonBuilder(Set<TypeAdapterFactory> factories, Map<Type, Object> adapters, Map<Class, Object> hiearchyAdapters) {
    GsonBuilder builder = new GsonBuilder()
        .setDateFormat(ISO8601_DATE_FORMAT)
        .serializeSpecialFloatingPointValues() // Infinity and NaN
        .serializeNulls(); // Needed so we can clear fields in PartialModel document updates

    factories.forEach(builder::registerTypeAdapterFactory);
    adapters.forEach(builder::registerTypeAdapter);
    hiearchyAdapters.forEach(builder::registerTypeHierarchyAdapter);

    return builder;
}
项目:letv    文件:TypeAdapters.java   
public static <TT> TypeAdapterFactory newEnumTypeHierarchyFactory() {
    return new TypeAdapterFactory() {
        public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
            Class<? super T> rawType = typeToken.getRawType();
            if (!Enum.class.isAssignableFrom(rawType) || rawType == Enum.class) {
                return null;
            }
            if (!rawType.isEnum()) {
                rawType = rawType.getSuperclass();
            }
            return new EnumTypeAdapter(rawType);
        }
    };
}
项目:letv    文件:TypeAdapters.java   
public static <TT> TypeAdapterFactory newFactory(final TypeToken<TT> type, final TypeAdapter<TT> typeAdapter) {
    return new TypeAdapterFactory() {
        public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
            return typeToken.equals(type) ? typeAdapter : null;
        }
    };
}
项目:letv    文件:TypeAdapters.java   
public static <TT> TypeAdapterFactory newFactory(final Class<TT> type, final TypeAdapter<TT> typeAdapter) {
    return new TypeAdapterFactory() {
        public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
            return typeToken.getRawType() == type ? typeAdapter : null;
        }

        public String toString() {
            return "Factory[type=" + type.getName() + ",adapter=" + typeAdapter + "]";
        }
    };
}
项目:letv    文件:TypeAdapters.java   
public static <TT> TypeAdapterFactory newFactory(final Class<TT> unboxed, final Class<TT> boxed, final TypeAdapter<? super TT> typeAdapter) {
    return new TypeAdapterFactory() {
        public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
            Class<? super T> rawType = typeToken.getRawType();
            return (rawType == unboxed || rawType == boxed) ? typeAdapter : null;
        }

        public String toString() {
            return "Factory[type=" + boxed.getName() + "+" + unboxed.getName() + ",adapter=" + typeAdapter + "]";
        }
    };
}
项目:letv    文件:TypeAdapters.java   
public static <TT> TypeAdapterFactory newFactoryForMultipleTypes(final Class<TT> base, final Class<? extends TT> sub, final TypeAdapter<? super TT> typeAdapter) {
    return new TypeAdapterFactory() {
        public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
            Class<? super T> rawType = typeToken.getRawType();
            return (rawType == base || rawType == sub) ? typeAdapter : null;
        }

        public String toString() {
            return "Factory[type=" + base.getName() + "+" + sub.getName() + ",adapter=" + typeAdapter + "]";
        }
    };
}
项目:letv    文件:TypeAdapters.java   
public static <TT> TypeAdapterFactory newTypeHierarchyFactory(final Class<TT> clazz, final TypeAdapter<TT> typeAdapter) {
    return new TypeAdapterFactory() {
        public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
            return clazz.isAssignableFrom(typeToken.getRawType()) ? typeAdapter : null;
        }

        public String toString() {
            return "Factory[typeHierarchy=" + clazz.getName() + ",adapter=" + typeAdapter + "]";
        }
    };
}
项目:odoo-work    文件:TypeAdapters.java   
public static <TT> TypeAdapterFactory newFactory(
    final TypeToken<TT> type, final TypeAdapter<TT> typeAdapter) {
  return new TypeAdapterFactory() {
    @SuppressWarnings("unchecked") // we use a runtime check to make sure the 'T's equal
    public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
      return typeToken.equals(type) ? (TypeAdapter<T>) typeAdapter : null;
    }
  };
}
项目:odoo-work    文件:TypeAdapters.java   
public static <TT> TypeAdapterFactory newFactory(
    final Class<TT> type, final TypeAdapter<TT> typeAdapter) {
  return new TypeAdapterFactory() {
    @SuppressWarnings("unchecked") // we use a runtime check to make sure the 'T's equal
    public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
      return typeToken.getRawType() == type ? (TypeAdapter<T>) typeAdapter : null;
    }
    @Override public String toString() {
      return "Factory[type=" + type.getName() + ",adapter=" + typeAdapter + "]";
    }
  };
}
项目:odoo-work    文件:TypeAdapters.java   
public static <TT> TypeAdapterFactory newFactory(
    final Class<TT> unboxed, final Class<TT> boxed, final TypeAdapter<? super TT> typeAdapter) {
  return new TypeAdapterFactory() {
    @SuppressWarnings("unchecked") // we use a runtime check to make sure the 'T's equal
    public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
      Class<? super T> rawType = typeToken.getRawType();
      return (rawType == unboxed || rawType == boxed) ? (TypeAdapter<T>) typeAdapter : null;
    }
    @Override public String toString() {
      return "Factory[type=" + boxed.getName()
          + "+" + unboxed.getName() + ",adapter=" + typeAdapter + "]";
    }
  };
}
项目:odoo-work    文件:TypeAdapters.java   
public static <TT> TypeAdapterFactory newFactoryForMultipleTypes(final Class<TT> base,
    final Class<? extends TT> sub, final TypeAdapter<? super TT> typeAdapter) {
  return new TypeAdapterFactory() {
    @SuppressWarnings("unchecked") // we use a runtime check to make sure the 'T's equal
    public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
      Class<? super T> rawType = typeToken.getRawType();
      return (rawType == base || rawType == sub) ? (TypeAdapter<T>) typeAdapter : null;
    }
    @Override public String toString() {
      return "Factory[type=" + base.getName()
          + "+" + sub.getName() + ",adapter=" + typeAdapter + "]";
    }
  };
}
项目:odoo-work    文件:TypeAdapters.java   
public static <TT> TypeAdapterFactory newTypeHierarchyFactory(
    final Class<TT> clazz, final TypeAdapter<TT> typeAdapter) {
  return new TypeAdapterFactory() {
    @SuppressWarnings("unchecked")
    public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
      return clazz.isAssignableFrom(typeToken.getRawType()) ? (TypeAdapter<T>) typeAdapter : null;
    }
    @Override public String toString() {
      return "Factory[typeHierarchy=" + clazz.getName() + ",adapter=" + typeAdapter + "]";
    }
  };
}
项目:lams    文件:TypeAdapters.java   
public static TypeAdapterFactory newEnumTypeHierarchyFactory() {
  return new TypeAdapterFactory() {
    @SuppressWarnings({"rawtypes", "unchecked"})
    public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
      Class<? super T> rawType = typeToken.getRawType();
      if (!Enum.class.isAssignableFrom(rawType) || rawType == Enum.class) {
        return null;
      }
      if (!rawType.isEnum()) {
        rawType = rawType.getSuperclass(); // handle anonymous subclasses
      }
      return (TypeAdapter<T>) new EnumTypeAdapter(rawType);
    }
  };
}
项目:lams    文件:TypeAdapters.java   
public static <TT> TypeAdapterFactory newFactory(
    final TypeToken<TT> type, final TypeAdapter<TT> typeAdapter) {
  return new TypeAdapterFactory() {
    @SuppressWarnings("unchecked") // we use a runtime check to make sure the 'T's equal
    public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
      return typeToken.equals(type) ? (TypeAdapter<T>) typeAdapter : null;
    }
  };
}
项目:lams    文件:TypeAdapters.java   
public static <TT> TypeAdapterFactory newFactory(
    final Class<TT> type, final TypeAdapter<TT> typeAdapter) {
  return new TypeAdapterFactory() {
    @SuppressWarnings("unchecked") // we use a runtime check to make sure the 'T's equal
    public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
      return typeToken.getRawType() == type ? (TypeAdapter<T>) typeAdapter : null;
    }
    @Override public String toString() {
      return "Factory[type=" + type.getName() + ",adapter=" + typeAdapter + "]";
    }
  };
}
项目:lams    文件:TypeAdapters.java   
public static <TT> TypeAdapterFactory newFactory(
    final Class<TT> unboxed, final Class<TT> boxed, final TypeAdapter<? super TT> typeAdapter) {
  return new TypeAdapterFactory() {
    @SuppressWarnings("unchecked") // we use a runtime check to make sure the 'T's equal
    public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
      Class<? super T> rawType = typeToken.getRawType();
      return (rawType == unboxed || rawType == boxed) ? (TypeAdapter<T>) typeAdapter : null;
    }
    @Override public String toString() {
      return "Factory[type=" + boxed.getName()
          + "+" + unboxed.getName() + ",adapter=" + typeAdapter + "]";
    }
  };
}
项目:lams    文件:TypeAdapters.java   
public static <TT> TypeAdapterFactory newFactoryForMultipleTypes(final Class<TT> base,
    final Class<? extends TT> sub, final TypeAdapter<? super TT> typeAdapter) {
  return new TypeAdapterFactory() {
    @SuppressWarnings("unchecked") // we use a runtime check to make sure the 'T's equal
    public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
      Class<? super T> rawType = typeToken.getRawType();
      return (rawType == base || rawType == sub) ? (TypeAdapter<T>) typeAdapter : null;
    }
    @Override public String toString() {
      return "Factory[type=" + base.getName()
          + "+" + sub.getName() + ",adapter=" + typeAdapter + "]";
    }
  };
}
项目:lams    文件:TypeAdapters.java   
public static <TT> TypeAdapterFactory newTypeHierarchyFactory(
    final Class<TT> clazz, final TypeAdapter<TT> typeAdapter) {
  return new TypeAdapterFactory() {
    @SuppressWarnings("unchecked")
    public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
      return clazz.isAssignableFrom(typeToken.getRawType()) ? (TypeAdapter<T>) typeAdapter : null;
    }
    @Override public String toString() {
      return "Factory[typeHierarchy=" + clazz.getName() + ",adapter=" + typeAdapter + "]";
    }
  };
}
项目:boohee_v5.6    文件:TypeAdapters.java   
public static TypeAdapterFactory newEnumTypeHierarchyFactory() {
    return new TypeAdapterFactory() {
        public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
            Class<? super T> rawType = typeToken.getRawType();
            if (!Enum.class.isAssignableFrom(rawType) || rawType == Enum.class) {
                return null;
            }
            if (!rawType.isEnum()) {
                rawType = rawType.getSuperclass();
            }
            return new EnumTypeAdapter(rawType);
        }
    };
}
项目:boohee_v5.6    文件:TypeAdapters.java   
public static <TT> TypeAdapterFactory newFactory(final TypeToken<TT> type, final
TypeAdapter<TT> typeAdapter) {
    return new TypeAdapterFactory() {
        public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
            return typeToken.equals(type) ? typeAdapter : null;
        }
    };
}
项目:boohee_v5.6    文件:TypeAdapters.java   
public static <TT> TypeAdapterFactory newFactory(final Class<TT> type, final TypeAdapter<TT>
        typeAdapter) {
    return new TypeAdapterFactory() {
        public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
            return typeToken.getRawType() == type ? typeAdapter : null;
        }

        public String toString() {
            return "Factory[type=" + type.getName() + ",adapter=" + typeAdapter + "]";
        }
    };
}
项目:boohee_v5.6    文件:TypeAdapters.java   
public static <TT> TypeAdapterFactory newFactory(final Class<TT> unboxed, final Class<TT>
        boxed, final TypeAdapter<? super TT> typeAdapter) {
    return new TypeAdapterFactory() {
        public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
            Class<? super T> rawType = typeToken.getRawType();
            return (rawType == unboxed || rawType == boxed) ? typeAdapter : null;
        }

        public String toString() {
            return "Factory[type=" + boxed.getName() + SocializeConstants.OP_DIVIDER_PLUS +
                    unboxed.getName() + ",adapter=" + typeAdapter + "]";
        }
    };
}
项目:boohee_v5.6    文件:TypeAdapters.java   
public static <TT> TypeAdapterFactory newFactoryForMultipleTypes(final Class<TT> base, final
Class<? extends TT> sub, final TypeAdapter<? super TT> typeAdapter) {
    return new TypeAdapterFactory() {
        public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
            Class<? super T> rawType = typeToken.getRawType();
            return (rawType == base || rawType == sub) ? typeAdapter : null;
        }

        public String toString() {
            return "Factory[type=" + base.getName() + SocializeConstants.OP_DIVIDER_PLUS + sub.getName() + ",adapter=" + typeAdapter + "]";
        }
    };
}
项目:boohee_v5.6    文件:TypeAdapters.java   
public static <TT> TypeAdapterFactory newTypeHierarchyFactory(final Class<TT> clazz, final TypeAdapter<TT> typeAdapter) {
    return new TypeAdapterFactory() {
        public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
            return clazz.isAssignableFrom(typeToken.getRawType()) ? typeAdapter : null;
        }

        public String toString() {
            return "Factory[typeHierarchy=" + clazz.getName() + ",adapter=" + typeAdapter + "]";
        }
    };
}
项目:boohee_v5.6    文件:JsonAdapterAnnotationTypeAdapterFactory.java   
static TypeAdapter<?> getTypeAdapter(ConstructorConstructor constructorConstructor, Gson
        gson, TypeToken<?> fieldType, JsonAdapter annotation) {
    Class<?> value = annotation.value();
    if (TypeAdapter.class.isAssignableFrom(value)) {
        return (TypeAdapter) constructorConstructor.get(TypeToken.get((Class) value))
                .construct();
    }
    if (TypeAdapterFactory.class.isAssignableFrom(value)) {
        return ((TypeAdapterFactory) constructorConstructor.get(TypeToken.get((Class) value))
                .construct()).create(gson, fieldType);
    }
    throw new IllegalArgumentException("@JsonAdapter value must be TypeAdapter or " +
            "TypeAdapterFactory reference.");
}
项目:greenbeans    文件:CategoriesTypeAdapter.java   
public static TypeAdapterFactory factory(EncryptorProviderService encryptorProviderService) {
    return new TypeAdapterFactory() {

        @SuppressWarnings("unchecked")
        @Override
        public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
            if (Categories.class.isAssignableFrom(type.getRawType())) {
                return (TypeAdapter<T>) new CategoriesTypeAdapter(gson, encryptorProviderService);
            }
            return null;
        }
    };
}
项目:greenbeans    文件:TransactionsTypeAdapter.java   
public static TypeAdapterFactory factory(EncryptorProviderService encryptorProviderService) {
    return new TypeAdapterFactory() {

        @SuppressWarnings("unchecked")
        @Override
        public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
            if (Transactions.class.isAssignableFrom(type.getRawType())) {
                return (TypeAdapter<T>) new TransactionsTypeAdapter(gson, encryptorProviderService);
            }
            return null;
        }
    };
}
项目:GitHubAndroidOAuth    文件:AutoGsonAdapterFactory.java   
public static TypeAdapterFactory create() {
    final TypeAdapterFactory factory = new AutoValueGson_AutoGsonAdapterFactory();

    return new TypeAdapterFactory() {
        @Override
        public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
            TypeAdapter<T> typeAdapter = factory.create(gson, type);
            return typeAdapter != null ? typeAdapter.nullSafe() : null;
        }
    };
}