com.google.gson.internal.ObjectConstructor Java Examples

The following examples show how to use com.google.gson.internal.ObjectConstructor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: gson   Author: google   File: MapTypeAdapterFactory.java    License: Apache License 2.0 6 votes vote down vote up
@Override public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
  Type type = typeToken.getType();

  Class<? super T> rawType = typeToken.getRawType();
  if (!Map.class.isAssignableFrom(rawType)) {
    return null;
  }

  Class<?> rawTypeOfSrc = $Gson$Types.getRawType(type);
  Type[] keyAndValueTypes = $Gson$Types.getMapKeyAndValueTypes(type, rawTypeOfSrc);
  TypeAdapter<?> keyAdapter = getKeyAdapter(gson, keyAndValueTypes[0]);
  TypeAdapter<?> valueAdapter = gson.getAdapter(TypeToken.get(keyAndValueTypes[1]));
  ObjectConstructor<T> constructor = constructorConstructor.get(typeToken);

  @SuppressWarnings({"unchecked", "rawtypes"})
  // we don't define a type parameter for the key or value types
  TypeAdapter<T> result = new Adapter(gson, keyAndValueTypes[0], keyAdapter,
      keyAndValueTypes[1], valueAdapter, constructor);
  return result;
}
 
Example #2
Source Project: gson   Author: google   File: CollectionTypeAdapterFactory.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
  Type type = typeToken.getType();

  Class<? super T> rawType = typeToken.getRawType();
  if (!Collection.class.isAssignableFrom(rawType)) {
    return null;
  }

  Type elementType = $Gson$Types.getCollectionElementType(type, rawType);
  TypeAdapter<?> elementTypeAdapter = gson.getAdapter(TypeToken.get(elementType));
  ObjectConstructor<T> constructor = constructorConstructor.get(typeToken);

  @SuppressWarnings({"unchecked", "rawtypes"}) // create() doesn't define a type parameter
  TypeAdapter<T> result = new Adapter(gson, elementType, elementTypeAdapter, constructor);
  return result;
}
 
Example #3
Source Project: salt-netapi-client   Author: SUSE   File: CollectionTypeAdapterFactory.java    License: MIT License 6 votes vote down vote up
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
    Type type = typeToken.getType();

    Class<? super T> rawType = typeToken.getRawType();
    if (!Collection.class.isAssignableFrom(rawType)) {
        return null;
    }
    Type elementType = $Gson$Types.getCollectionElementType(type, rawType);

    TypeAdapter<?> elementTypeAdapter = gson.getAdapter(TypeToken.get(elementType));
    ObjectConstructor<T> constructor = constructorConstructor.get(typeToken);

    @SuppressWarnings({ "unchecked", "rawtypes" })
    TypeAdapter<T> result = new Adapter(elementTypeAdapter, constructor);
    return result;
}
 
Example #4
Source Project: framework   Author: Odoo-mobile   File: MapTypeAdapterFactory.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
  Type type = typeToken.getType();

  Class<? super T> rawType = typeToken.getRawType();
  if (!Map.class.isAssignableFrom(rawType)) {
    return null;
  }

  Class<?> rawTypeOfSrc = $Gson$Types.getRawType(type);
  Type[] keyAndValueTypes = $Gson$Types.getMapKeyAndValueTypes(type, rawTypeOfSrc);
  TypeAdapter<?> keyAdapter = getKeyAdapter(gson, keyAndValueTypes[0]);
  TypeAdapter<?> valueAdapter = gson.getAdapter(TypeToken.get(keyAndValueTypes[1]));
  ObjectConstructor<T> constructor = constructorConstructor.get(typeToken);

  @SuppressWarnings({"unchecked", "rawtypes"})
  // we don't define a type parameter for the key or value types
  TypeAdapter<T> result = new Adapter(gson, keyAndValueTypes[0], keyAdapter,
      keyAndValueTypes[1], valueAdapter, constructor);
  return result;
}
 
Example #5
Source Project: framework   Author: Odoo-mobile   File: CollectionTypeAdapterFactory.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
  Type type = typeToken.getType();

  Class<? super T> rawType = typeToken.getRawType();
  if (!Collection.class.isAssignableFrom(rawType)) {
    return null;
  }

  Type elementType = $Gson$Types.getCollectionElementType(type, rawType);
  TypeAdapter<?> elementTypeAdapter = gson.getAdapter(TypeToken.get(elementType));
  ObjectConstructor<T> constructor = constructorConstructor.get(typeToken);

  @SuppressWarnings({"unchecked", "rawtypes"}) // create() doesn't define a type parameter
  TypeAdapter<T> result = new Adapter(gson, elementType, elementTypeAdapter, constructor);
  return result;
}
 
Example #6
Source Project: lastaflute   Author: lastaflute   File: LaReflectiveTypeAdapterFactory.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public <T> TypeAdapter<T> create(Gson gson, final TypeToken<T> type) {
    final Class<? super T> raw = type.getRawType();
    if (!Object.class.isAssignableFrom(raw)) {
        return null; // it's a primitive!
    }
    final ObjectConstructor<T> constructor = constructorConstructor.get(type);
    return new ReflextiveAdapter<T>(constructor, getBoundFields(gson, type, raw));
}
 
Example #7
Source Project: MiBandDecompiled   Author: vishnudevk   File: f.java    License: Apache License 2.0 5 votes vote down vote up
public f(MapTypeAdapterFactory maptypeadapterfactory, Gson gson, Type type, TypeAdapter typeadapter, Type type1, TypeAdapter typeadapter1, ObjectConstructor objectconstructor)
{
    a = maptypeadapterfactory;
    super();
    b = new m(gson, typeadapter, type);
    c = new m(gson, typeadapter1, type1);
    d = objectconstructor;
}
 
Example #8
Source Project: gson   Author: google   File: MapTypeAdapterFactory.java    License: Apache License 2.0 5 votes vote down vote up
public Adapter(Gson context, Type keyType, TypeAdapter<K> keyTypeAdapter,
    Type valueType, TypeAdapter<V> valueTypeAdapter,
    ObjectConstructor<? extends Map<K, V>> constructor) {
  this.keyTypeAdapter =
    new TypeAdapterRuntimeTypeWrapper<K>(context, keyTypeAdapter, keyType);
  this.valueTypeAdapter =
    new TypeAdapterRuntimeTypeWrapper<V>(context, valueTypeAdapter, valueType);
  this.constructor = constructor;
}
 
Example #9
Source Project: gson   Author: google   File: CollectionTypeAdapterFactory.java    License: Apache License 2.0 5 votes vote down vote up
public Adapter(Gson context, Type elementType,
    TypeAdapter<E> elementTypeAdapter,
    ObjectConstructor<? extends Collection<E>> constructor) {
  this.elementTypeAdapter =
      new TypeAdapterRuntimeTypeWrapper<E>(context, elementTypeAdapter, elementType);
  this.constructor = constructor;
}
 
Example #10
Source Project: gson   Author: google   File: ReflectiveTypeAdapterFactory.java    License: Apache License 2.0 5 votes vote down vote up
@Override public <T> TypeAdapter<T> create(Gson gson, final TypeToken<T> type) {
  Class<? super T> raw = type.getRawType();

  if (!Object.class.isAssignableFrom(raw)) {
    return null; // it's a primitive!
  }

  ObjectConstructor<T> constructor = constructorConstructor.get(type);
  return new Adapter<T>(constructor, getBoundFields(gson, type, raw));
}
 
Example #11
Source Project: framework   Author: Odoo-mobile   File: MapTypeAdapterFactory.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
public Adapter(Gson context, Type keyType, TypeAdapter<K> keyTypeAdapter,
    Type valueType, TypeAdapter<V> valueTypeAdapter,
    ObjectConstructor<? extends Map<K, V>> constructor) {
  this.keyTypeAdapter =
    new TypeAdapterRuntimeTypeWrapper<K>(context, keyTypeAdapter, keyType);
  this.valueTypeAdapter =
    new TypeAdapterRuntimeTypeWrapper<V>(context, valueTypeAdapter, valueType);
  this.constructor = constructor;
}
 
Example #12
Source Project: framework   Author: Odoo-mobile   File: CollectionTypeAdapterFactory.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
public Adapter(Gson context, Type elementType,
    TypeAdapter<E> elementTypeAdapter,
    ObjectConstructor<? extends Collection<E>> constructor) {
  this.elementTypeAdapter =
      new TypeAdapterRuntimeTypeWrapper<E>(context, elementTypeAdapter, elementType);
  this.constructor = constructor;
}
 
Example #13
Source Project: framework   Author: Odoo-mobile   File: ReflectiveTypeAdapterFactory.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
public <T> TypeAdapter<T> create(Gson gson, final TypeToken<T> type) {
  Class<? super T> raw = type.getRawType();

  if (!Object.class.isAssignableFrom(raw)) {
    return null; // it's a primitive!
  }

  ObjectConstructor<T> constructor = constructorConstructor.get(type);
  return new Adapter<T>(constructor, getBoundFields(gson, type, raw));
}
 
Example #14
Source Project: letv   Author: JackChan1999   File: MapTypeAdapterFactory.java    License: Apache License 2.0 4 votes vote down vote up
public Adapter(Gson context, Type keyType, TypeAdapter<K> keyTypeAdapter, Type valueType, TypeAdapter<V> valueTypeAdapter, ObjectConstructor<? extends Map<K, V>> constructor) {
    this.keyTypeAdapter = new TypeAdapterRuntimeTypeWrapper(context, keyTypeAdapter, keyType);
    this.valueTypeAdapter = new TypeAdapterRuntimeTypeWrapper(context, valueTypeAdapter, valueType);
    this.constructor = constructor;
}
 
Example #15
Source Project: letv   Author: JackChan1999   File: CollectionTypeAdapterFactory.java    License: Apache License 2.0 4 votes vote down vote up
public Adapter(Gson context, Type elementType, TypeAdapter<E> elementTypeAdapter, ObjectConstructor<? extends Collection<E>> constructor) {
    this.elementTypeAdapter = new TypeAdapterRuntimeTypeWrapper(context, elementTypeAdapter, elementType);
    this.constructor = constructor;
}
 
Example #16
Source Project: letv   Author: JackChan1999   File: ReflectiveTypeAdapterFactory.java    License: Apache License 2.0 4 votes vote down vote up
private Adapter(ObjectConstructor<T> constructor, Map<String, BoundField> boundFields) {
    this.constructor = constructor;
    this.boundFields = boundFields;
}
 
Example #17
Source Project: lastaflute   Author: lastaflute   File: LaReflectiveTypeAdapterFactory.java    License: Apache License 2.0 4 votes vote down vote up
protected ReflextiveAdapter(ObjectConstructor<PROPERTY> constructor, Map<String, LaBoundField> boundFields) {
    this.constructor = constructor;
    this.boundFields = boundFields;
}
 
Example #18
Source Project: MiBandDecompiled   Author: vishnudevk   File: b.java    License: Apache License 2.0 4 votes vote down vote up
public b(Gson gson, Type type, TypeAdapter typeadapter, ObjectConstructor objectconstructor)
{
    a = new m(gson, typeadapter, type);
    b = objectconstructor;
}
 
Example #19
Source Project: gson   Author: google   File: ReflectiveTypeAdapterFactory.java    License: Apache License 2.0 4 votes vote down vote up
Adapter(ObjectConstructor<T> constructor, Map<String, BoundField> boundFields) {
  this.constructor = constructor;
  this.boundFields = boundFields;
}
 
Example #20
Source Project: salt-netapi-client   Author: SUSE   File: CollectionTypeAdapterFactory.java    License: MIT License 4 votes vote down vote up
public Adapter(TypeAdapter<E> elementAdapter, ObjectConstructor<? extends
        Collection<E>> constructor) {
    this.constructor = constructor;
    this.elementTypeAdapter = elementAdapter;
}
 
Example #21
Source Project: framework   Author: Odoo-mobile   File: ReflectiveTypeAdapterFactory.java    License: GNU Affero General Public License v3.0 4 votes vote down vote up
private Adapter(ObjectConstructor<T> constructor, Map<String, BoundField> boundFields) {
  this.constructor = constructor;
  this.boundFields = boundFields;
}