com.google.gson.internal.ConstructorConstructor Java Examples
The following examples show how to use
com.google.gson.internal.ConstructorConstructor.
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 File: JsonAdapterAnnotationTypeAdapterFactory.java From framework with GNU Affero General Public License v3.0 | 6 votes |
@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."); }
Example #2
Source File: GsonJsonEngine.java From lastaflute with Apache License 2.0 | 5 votes |
protected LaReflectiveTypeAdapterFactory createReflectiveTypeAdapterFactory(Gson newGson, Object factory) { final ConstructorConstructor constructorConstructor = getConstructorConstructor(factory); final JsonAdapterAnnotationTypeAdapterFactory jsonAdapterFactory = getJsonAdapterFactory(factory); final FieldNamingStrategy fieldNamingStrategy = newGson.fieldNamingStrategy(); final Excluder excluder = newGson.excluder(); return new LaReflectiveTypeAdapterFactory(constructorConstructor, fieldNamingStrategy, excluder, jsonAdapterFactory); }
Example #3
Source File: LaReflectiveTypeAdapterFactory.java From lastaflute with Apache License 2.0 | 5 votes |
public LaReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor, FieldNamingStrategy fieldNamingPolicy, Excluder excluder, JsonAdapterAnnotationTypeAdapterFactory jsonAdapterFactory) { this.constructorConstructor = constructorConstructor; this.fieldNamingPolicy = fieldNamingPolicy; this.excluder = excluder; this.jsonAdapterFactory = jsonAdapterFactory; }
Example #4
Source File: PropertiesTypeAdapter.java From smarthome with Eclipse Public License 2.0 | 5 votes |
public PropertiesTypeAdapter(Gson gson) { // obtain the default type adapters for String and Object classes keyAdapter = gson.getAdapter(String.class); valueAdapter = gson.getAdapter(Object.class); // obtain default gson objects constructor = new ConstructorConstructor(Collections.<Type, InstanceCreator<?>> emptyMap()); delegate = new MapTypeAdapterFactory(constructor, false).create(new Gson(), TOKEN); }
Example #5
Source File: ReflectiveTypeAdapterFactory.java From gson with Apache License 2.0 | 5 votes |
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor, FieldNamingStrategy fieldNamingPolicy, Excluder excluder, JsonAdapterAnnotationTypeAdapterFactory jsonAdapterFactory) { this.constructorConstructor = constructorConstructor; this.fieldNamingPolicy = fieldNamingPolicy; this.excluder = excluder; this.jsonAdapterFactory = jsonAdapterFactory; }
Example #6
Source File: JsonAdapterAnnotationTypeAdapterFactory.java From gson with Apache License 2.0 | 5 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) // Casts guarded by conditionals. TypeAdapter<?> getTypeAdapter(ConstructorConstructor constructorConstructor, Gson gson, TypeToken<?> type, JsonAdapter annotation) { Object instance = constructorConstructor.get(TypeToken.get(annotation.value())).construct(); TypeAdapter<?> typeAdapter; if (instance instanceof TypeAdapter) { typeAdapter = (TypeAdapter<?>) instance; } else if (instance instanceof TypeAdapterFactory) { typeAdapter = ((TypeAdapterFactory) instance).create(gson, type); } else if (instance instanceof JsonSerializer || instance instanceof JsonDeserializer) { JsonSerializer<?> serializer = instance instanceof JsonSerializer ? (JsonSerializer) instance : null; JsonDeserializer<?> deserializer = instance instanceof JsonDeserializer ? (JsonDeserializer) instance : null; typeAdapter = new TreeTypeAdapter(serializer, deserializer, gson, type, null); } else { throw new IllegalArgumentException("Invalid attempt to bind an instance of " + instance.getClass().getName() + " as a @JsonAdapter for " + type.toString() + ". @JsonAdapter value must be a TypeAdapter, TypeAdapterFactory," + " JsonSerializer or JsonDeserializer."); } if (typeAdapter != null && annotation.nullSafe()) { typeAdapter = typeAdapter.nullSafe(); } return typeAdapter; }
Example #7
Source File: MapTypeAdapterFactory.java From gson with Apache License 2.0 | 4 votes |
public MapTypeAdapterFactory(ConstructorConstructor constructorConstructor, boolean complexMapKeySerialization) { this.constructorConstructor = constructorConstructor; this.complexMapKeySerialization = complexMapKeySerialization; }
Example #8
Source File: ReflectiveTypeAdapterFactory.java From framework with GNU Affero General Public License v3.0 | 4 votes |
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor, FieldNamingStrategy fieldNamingPolicy, Excluder excluder) { this.constructorConstructor = constructorConstructor; this.fieldNamingPolicy = fieldNamingPolicy; this.excluder = excluder; }
Example #9
Source File: CollectionTypeAdapterFactory.java From framework with GNU Affero General Public License v3.0 | 4 votes |
public CollectionTypeAdapterFactory(ConstructorConstructor constructorConstructor) { this.constructorConstructor = constructorConstructor; }
Example #10
Source File: JsonAdapterAnnotationTypeAdapterFactory.java From framework with GNU Affero General Public License v3.0 | 4 votes |
public JsonAdapterAnnotationTypeAdapterFactory(ConstructorConstructor constructorConstructor) { this.constructorConstructor = constructorConstructor; }
Example #11
Source File: MapTypeAdapterFactory.java From framework with GNU Affero General Public License v3.0 | 4 votes |
public MapTypeAdapterFactory(ConstructorConstructor constructorConstructor, boolean complexMapKeySerialization) { this.constructorConstructor = constructorConstructor; this.complexMapKeySerialization = complexMapKeySerialization; }
Example #12
Source File: Gson.java From framework with GNU Affero General Public License v3.0 | 4 votes |
Gson(final Excluder excluder, final FieldNamingStrategy fieldNamingPolicy, final Map<Type, InstanceCreator<?>> instanceCreators, boolean serializeNulls, boolean complexMapKeySerialization, boolean generateNonExecutableGson, boolean htmlSafe, boolean prettyPrinting, boolean serializeSpecialFloatingPointValues, LongSerializationPolicy longSerializationPolicy, List<TypeAdapterFactory> typeAdapterFactories) { this.constructorConstructor = new ConstructorConstructor(instanceCreators); this.serializeNulls = serializeNulls; this.generateNonExecutableJson = generateNonExecutableGson; this.htmlSafe = htmlSafe; this.prettyPrinting = prettyPrinting; List<TypeAdapterFactory> factories = new ArrayList<TypeAdapterFactory>(); // built-in type adapters that cannot be overridden factories.add(TypeAdapters.JSON_ELEMENT_FACTORY); factories.add(ObjectTypeAdapter.FACTORY); // the excluder must precede all adapters that handle user-defined types factories.add(excluder); // user's type adapters factories.addAll(typeAdapterFactories); // type adapters for basic platform types factories.add(TypeAdapters.STRING_FACTORY); factories.add(TypeAdapters.INTEGER_FACTORY); factories.add(TypeAdapters.BOOLEAN_FACTORY); factories.add(TypeAdapters.BYTE_FACTORY); factories.add(TypeAdapters.SHORT_FACTORY); factories.add(TypeAdapters.newFactory(long.class, Long.class, longAdapter(longSerializationPolicy))); factories.add(TypeAdapters.newFactory(double.class, Double.class, doubleAdapter(serializeSpecialFloatingPointValues))); factories.add(TypeAdapters.newFactory(float.class, Float.class, floatAdapter(serializeSpecialFloatingPointValues))); factories.add(TypeAdapters.NUMBER_FACTORY); factories.add(TypeAdapters.CHARACTER_FACTORY); factories.add(TypeAdapters.STRING_BUILDER_FACTORY); factories.add(TypeAdapters.STRING_BUFFER_FACTORY); factories.add(TypeAdapters.newFactory(BigDecimal.class, TypeAdapters.BIG_DECIMAL)); factories.add(TypeAdapters.newFactory(BigInteger.class, TypeAdapters.BIG_INTEGER)); factories.add(TypeAdapters.URL_FACTORY); factories.add(TypeAdapters.URI_FACTORY); factories.add(TypeAdapters.UUID_FACTORY); factories.add(TypeAdapters.LOCALE_FACTORY); factories.add(TypeAdapters.INET_ADDRESS_FACTORY); factories.add(TypeAdapters.BIT_SET_FACTORY); factories.add(DateTypeAdapter.FACTORY); factories.add(TypeAdapters.CALENDAR_FACTORY); factories.add(TimeTypeAdapter.FACTORY); factories.add(SqlDateTypeAdapter.FACTORY); factories.add(TypeAdapters.TIMESTAMP_FACTORY); factories.add(ArrayTypeAdapter.FACTORY); factories.add(TypeAdapters.CLASS_FACTORY); // type adapters for composite and user-defined types factories.add(new CollectionTypeAdapterFactory(constructorConstructor)); factories.add(new MapTypeAdapterFactory(constructorConstructor, complexMapKeySerialization)); factories.add(new JsonAdapterAnnotationTypeAdapterFactory(constructorConstructor)); factories.add(TypeAdapters.ENUM_FACTORY); factories.add(new ReflectiveTypeAdapterFactory( constructorConstructor, fieldNamingPolicy, excluder)); this.factories = Collections.unmodifiableList(factories); }
Example #13
Source File: CollectionTypeAdapterFactory.java From salt-netapi-client with MIT License | 4 votes |
public CollectionTypeAdapterFactory() { this.constructorConstructor = new ConstructorConstructor(new HashMap<>()); }
Example #14
Source File: GraphAdapterBuilder.java From gson with Apache License 2.0 | 4 votes |
public GraphAdapterBuilder() { this.instanceCreators = new HashMap<Type, InstanceCreator<?>>(); this.constructorConstructor = new ConstructorConstructor(instanceCreators); }
Example #15
Source File: CollectionTypeAdapterFactory.java From gson with Apache License 2.0 | 4 votes |
public CollectionTypeAdapterFactory(ConstructorConstructor constructorConstructor) { this.constructorConstructor = constructorConstructor; }
Example #16
Source File: JsonAdapterAnnotationTypeAdapterFactory.java From gson with Apache License 2.0 | 4 votes |
public JsonAdapterAnnotationTypeAdapterFactory(ConstructorConstructor constructorConstructor) { this.constructorConstructor = constructorConstructor; }
Example #17
Source File: MapTypeAdapterFactory.java From letv with Apache License 2.0 | 4 votes |
public MapTypeAdapterFactory(ConstructorConstructor constructorConstructor, boolean complexMapKeySerialization) { this.constructorConstructor = constructorConstructor; this.complexMapKeySerialization = complexMapKeySerialization; }
Example #18
Source File: Gson.java From gson with Apache License 2.0 | 4 votes |
Gson(Excluder excluder, FieldNamingStrategy fieldNamingStrategy, Map<Type, InstanceCreator<?>> instanceCreators, boolean serializeNulls, boolean complexMapKeySerialization, boolean generateNonExecutableGson, boolean htmlSafe, boolean prettyPrinting, boolean lenient, boolean serializeSpecialFloatingPointValues, LongSerializationPolicy longSerializationPolicy, String datePattern, int dateStyle, int timeStyle, List<TypeAdapterFactory> builderFactories, List<TypeAdapterFactory> builderHierarchyFactories, List<TypeAdapterFactory> factoriesToBeAdded) { this.excluder = excluder; this.fieldNamingStrategy = fieldNamingStrategy; this.instanceCreators = instanceCreators; this.constructorConstructor = new ConstructorConstructor(instanceCreators); this.serializeNulls = serializeNulls; this.complexMapKeySerialization = complexMapKeySerialization; this.generateNonExecutableJson = generateNonExecutableGson; this.htmlSafe = htmlSafe; this.prettyPrinting = prettyPrinting; this.lenient = lenient; this.serializeSpecialFloatingPointValues = serializeSpecialFloatingPointValues; this.longSerializationPolicy = longSerializationPolicy; this.datePattern = datePattern; this.dateStyle = dateStyle; this.timeStyle = timeStyle; this.builderFactories = builderFactories; this.builderHierarchyFactories = builderHierarchyFactories; List<TypeAdapterFactory> factories = new ArrayList<TypeAdapterFactory>(); // built-in type adapters that cannot be overridden factories.add(TypeAdapters.JSON_ELEMENT_FACTORY); factories.add(ObjectTypeAdapter.FACTORY); // the excluder must precede all adapters that handle user-defined types factories.add(excluder); // users' type adapters factories.addAll(factoriesToBeAdded); // type adapters for basic platform types factories.add(TypeAdapters.STRING_FACTORY); factories.add(TypeAdapters.INTEGER_FACTORY); factories.add(TypeAdapters.BOOLEAN_FACTORY); factories.add(TypeAdapters.BYTE_FACTORY); factories.add(TypeAdapters.SHORT_FACTORY); TypeAdapter<Number> longAdapter = longAdapter(longSerializationPolicy); factories.add(TypeAdapters.newFactory(long.class, Long.class, longAdapter)); factories.add(TypeAdapters.newFactory(double.class, Double.class, doubleAdapter(serializeSpecialFloatingPointValues))); factories.add(TypeAdapters.newFactory(float.class, Float.class, floatAdapter(serializeSpecialFloatingPointValues))); factories.add(TypeAdapters.NUMBER_FACTORY); factories.add(TypeAdapters.ATOMIC_INTEGER_FACTORY); factories.add(TypeAdapters.ATOMIC_BOOLEAN_FACTORY); factories.add(TypeAdapters.newFactory(AtomicLong.class, atomicLongAdapter(longAdapter))); factories.add(TypeAdapters.newFactory(AtomicLongArray.class, atomicLongArrayAdapter(longAdapter))); factories.add(TypeAdapters.ATOMIC_INTEGER_ARRAY_FACTORY); factories.add(TypeAdapters.CHARACTER_FACTORY); factories.add(TypeAdapters.STRING_BUILDER_FACTORY); factories.add(TypeAdapters.STRING_BUFFER_FACTORY); factories.add(TypeAdapters.newFactory(BigDecimal.class, TypeAdapters.BIG_DECIMAL)); factories.add(TypeAdapters.newFactory(BigInteger.class, TypeAdapters.BIG_INTEGER)); factories.add(TypeAdapters.URL_FACTORY); factories.add(TypeAdapters.URI_FACTORY); factories.add(TypeAdapters.UUID_FACTORY); factories.add(TypeAdapters.CURRENCY_FACTORY); factories.add(TypeAdapters.LOCALE_FACTORY); factories.add(TypeAdapters.INET_ADDRESS_FACTORY); factories.add(TypeAdapters.BIT_SET_FACTORY); factories.add(DateTypeAdapter.FACTORY); factories.add(TypeAdapters.CALENDAR_FACTORY); factories.add(TimeTypeAdapter.FACTORY); factories.add(SqlDateTypeAdapter.FACTORY); factories.add(TypeAdapters.TIMESTAMP_FACTORY); factories.add(ArrayTypeAdapter.FACTORY); factories.add(TypeAdapters.CLASS_FACTORY); // type adapters for composite and user-defined types factories.add(new CollectionTypeAdapterFactory(constructorConstructor)); factories.add(new MapTypeAdapterFactory(constructorConstructor, complexMapKeySerialization)); this.jsonAdapterFactory = new JsonAdapterAnnotationTypeAdapterFactory(constructorConstructor); factories.add(jsonAdapterFactory); factories.add(TypeAdapters.ENUM_FACTORY); factories.add(new ReflectiveTypeAdapterFactory( constructorConstructor, fieldNamingStrategy, excluder, jsonAdapterFactory)); this.factories = Collections.unmodifiableList(factories); }
Example #19
Source File: ReflectiveTypeAdapterFactory.java From MiBandDecompiled with Apache License 2.0 | 4 votes |
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorconstructor, FieldNamingStrategy fieldnamingstrategy, Excluder excluder) { a = constructorconstructor; b = fieldnamingstrategy; c = excluder; }
Example #20
Source File: CollectionTypeAdapterFactory.java From MiBandDecompiled with Apache License 2.0 | 4 votes |
public CollectionTypeAdapterFactory(ConstructorConstructor constructorconstructor) { a = constructorconstructor; }
Example #21
Source File: MapTypeAdapterFactory.java From MiBandDecompiled with Apache License 2.0 | 4 votes |
public MapTypeAdapterFactory(ConstructorConstructor constructorconstructor, boolean flag) { a = constructorconstructor; b = flag; }
Example #22
Source File: Gson.java From MiBandDecompiled with Apache License 2.0 | 4 votes |
Gson(Excluder excluder, FieldNamingStrategy fieldnamingstrategy, Map map, boolean flag, boolean flag1, boolean flag2, boolean flag3, boolean flag4, boolean flag5, LongSerializationPolicy longserializationpolicy, List list) { e = new ThreadLocal(); f = Collections.synchronizedMap(new HashMap()); b = new g(this); c = new h(this); h = new ConstructorConstructor(map); i = flag; k = flag2; j = flag3; l = flag4; ArrayList arraylist = new ArrayList(); arraylist.add(TypeAdapters.JSON_ELEMENT_FACTORY); arraylist.add(ObjectTypeAdapter.FACTORY); arraylist.add(excluder); arraylist.addAll(list); arraylist.add(TypeAdapters.STRING_FACTORY); arraylist.add(TypeAdapters.INTEGER_FACTORY); arraylist.add(TypeAdapters.BOOLEAN_FACTORY); arraylist.add(TypeAdapters.BYTE_FACTORY); arraylist.add(TypeAdapters.SHORT_FACTORY); arraylist.add(TypeAdapters.newFactory(Long.TYPE, java/lang/Long, a(longserializationpolicy))); arraylist.add(TypeAdapters.newFactory(Double.TYPE, java/lang/Double, a(flag5))); arraylist.add(TypeAdapters.newFactory(Float.TYPE, java/lang/Float, b(flag5))); arraylist.add(TypeAdapters.NUMBER_FACTORY); arraylist.add(TypeAdapters.CHARACTER_FACTORY); arraylist.add(TypeAdapters.STRING_BUILDER_FACTORY); arraylist.add(TypeAdapters.STRING_BUFFER_FACTORY); arraylist.add(TypeAdapters.newFactory(java/math/BigDecimal, TypeAdapters.BIG_DECIMAL)); arraylist.add(TypeAdapters.newFactory(java/math/BigInteger, TypeAdapters.BIG_INTEGER)); arraylist.add(TypeAdapters.URL_FACTORY); arraylist.add(TypeAdapters.URI_FACTORY); arraylist.add(TypeAdapters.UUID_FACTORY); arraylist.add(TypeAdapters.LOCALE_FACTORY); arraylist.add(TypeAdapters.INET_ADDRESS_FACTORY); arraylist.add(TypeAdapters.BIT_SET_FACTORY); arraylist.add(DateTypeAdapter.FACTORY); arraylist.add(TypeAdapters.CALENDAR_FACTORY); arraylist.add(TimeTypeAdapter.FACTORY); arraylist.add(SqlDateTypeAdapter.FACTORY); arraylist.add(TypeAdapters.TIMESTAMP_FACTORY); arraylist.add(ArrayTypeAdapter.FACTORY); arraylist.add(TypeAdapters.ENUM_FACTORY); arraylist.add(TypeAdapters.CLASS_FACTORY); arraylist.add(new CollectionTypeAdapterFactory(h)); arraylist.add(new MapTypeAdapterFactory(h, flag1)); arraylist.add(new ReflectiveTypeAdapterFactory(h, fieldnamingstrategy, excluder)); g = Collections.unmodifiableList(arraylist); }
Example #23
Source File: CollectionGsonAdaptable.java From lastaflute with Apache License 2.0 | 4 votes |
protected CollectionTypeAdapterFactory newCollectionTypeAdapterFactory(ConstructorConstructor constructor) { return new CollectionTypeAdapterFactory(constructor); }
Example #24
Source File: CollectionGsonAdaptable.java From lastaflute with Apache License 2.0 | 4 votes |
protected ConstructorConstructor createConstructorConstructor(Map<Type, InstanceCreator<?>> instanceCreators) { return new ConstructorConstructor(instanceCreators); }
Example #25
Source File: CollectionGsonAdaptable.java From lastaflute with Apache License 2.0 | 4 votes |
protected CollectionTypeAdapterFactory createEmbeddedFactory() { final Map<Type, InstanceCreator<?>> instanceCreators = prepareInstanceCreators(); final ConstructorConstructor constructor = createConstructorConstructor(instanceCreators); return newCollectionTypeAdapterFactory(constructor); }
Example #26
Source File: GsonJsonEngine.java From lastaflute with Apache License 2.0 | 4 votes |
protected ConstructorConstructor getConstructorConstructor(Object factory) { final Field field = DfReflectionUtil.getWholeField(factory.getClass(), "constructorConstructor"); return (ConstructorConstructor) DfReflectionUtil.getValueForcedly(field, factory); }
Example #27
Source File: ReflectiveTypeAdapterFactory.java From letv with Apache License 2.0 | 4 votes |
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor, FieldNamingStrategy fieldNamingPolicy, Excluder excluder) { this.constructorConstructor = constructorConstructor; this.fieldNamingPolicy = fieldNamingPolicy; this.excluder = excluder; }
Example #28
Source File: CollectionTypeAdapterFactory.java From letv with Apache License 2.0 | 4 votes |
public CollectionTypeAdapterFactory(ConstructorConstructor constructorConstructor) { this.constructorConstructor = constructorConstructor; }