Add more Gson
default constants to be used by GsonBuilder
(#2051)
This commit is contained in:
parent
ffcfb15f6c
commit
73216b2ad7
@ -111,6 +111,10 @@ public final class Gson {
|
|||||||
static final boolean DEFAULT_COMPLEX_MAP_KEYS = false;
|
static final boolean DEFAULT_COMPLEX_MAP_KEYS = false;
|
||||||
static final boolean DEFAULT_SPECIALIZE_FLOAT_VALUES = false;
|
static final boolean DEFAULT_SPECIALIZE_FLOAT_VALUES = false;
|
||||||
static final boolean DEFAULT_USE_JDK_UNSAFE = true;
|
static final boolean DEFAULT_USE_JDK_UNSAFE = true;
|
||||||
|
static final String DEFAULT_DATE_PATTERN = null;
|
||||||
|
static final FieldNamingStrategy DEFAULT_FIELD_NAMING_STRATEGY = FieldNamingPolicy.IDENTITY;
|
||||||
|
static final ToNumberStrategy DEFAULT_OBJECT_TO_NUMBER_STRATEGY = ToNumberPolicy.DOUBLE;
|
||||||
|
static final ToNumberStrategy DEFAULT_NUMBER_TO_NUMBER_STRATEGY = ToNumberPolicy.LAZILY_PARSED_NUMBER;
|
||||||
|
|
||||||
private static final TypeToken<?> NULL_KEY_SURROGATE = TypeToken.get(Object.class);
|
private static final TypeToken<?> NULL_KEY_SURROGATE = TypeToken.get(Object.class);
|
||||||
private static final String JSON_NON_EXECUTABLE_PREFIX = ")]}'\n";
|
private static final String JSON_NON_EXECUTABLE_PREFIX = ")]}'\n";
|
||||||
@ -187,14 +191,14 @@ public final class Gson {
|
|||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
public Gson() {
|
public Gson() {
|
||||||
this(Excluder.DEFAULT, FieldNamingPolicy.IDENTITY,
|
this(Excluder.DEFAULT, DEFAULT_FIELD_NAMING_STRATEGY,
|
||||||
Collections.<Type, InstanceCreator<?>>emptyMap(), DEFAULT_SERIALIZE_NULLS,
|
Collections.<Type, InstanceCreator<?>>emptyMap(), DEFAULT_SERIALIZE_NULLS,
|
||||||
DEFAULT_COMPLEX_MAP_KEYS, DEFAULT_JSON_NON_EXECUTABLE, DEFAULT_ESCAPE_HTML,
|
DEFAULT_COMPLEX_MAP_KEYS, DEFAULT_JSON_NON_EXECUTABLE, DEFAULT_ESCAPE_HTML,
|
||||||
DEFAULT_PRETTY_PRINT, DEFAULT_LENIENT, DEFAULT_SPECIALIZE_FLOAT_VALUES,
|
DEFAULT_PRETTY_PRINT, DEFAULT_LENIENT, DEFAULT_SPECIALIZE_FLOAT_VALUES,
|
||||||
DEFAULT_USE_JDK_UNSAFE,
|
DEFAULT_USE_JDK_UNSAFE,
|
||||||
LongSerializationPolicy.DEFAULT, null, DateFormat.DEFAULT, DateFormat.DEFAULT,
|
LongSerializationPolicy.DEFAULT, DEFAULT_DATE_PATTERN, DateFormat.DEFAULT, DateFormat.DEFAULT,
|
||||||
Collections.<TypeAdapterFactory>emptyList(), Collections.<TypeAdapterFactory>emptyList(),
|
Collections.<TypeAdapterFactory>emptyList(), Collections.<TypeAdapterFactory>emptyList(),
|
||||||
Collections.<TypeAdapterFactory>emptyList(), ToNumberPolicy.DOUBLE, ToNumberPolicy.LAZILY_PARSED_NUMBER);
|
Collections.<TypeAdapterFactory>emptyList(), DEFAULT_OBJECT_TO_NUMBER_STRATEGY, DEFAULT_NUMBER_TO_NUMBER_STRATEGY);
|
||||||
}
|
}
|
||||||
|
|
||||||
Gson(Excluder excluder, FieldNamingStrategy fieldNamingStrategy,
|
Gson(Excluder excluder, FieldNamingStrategy fieldNamingStrategy,
|
||||||
|
@ -35,9 +35,12 @@ import com.google.gson.reflect.TypeToken;
|
|||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
|
|
||||||
import static com.google.gson.Gson.DEFAULT_COMPLEX_MAP_KEYS;
|
import static com.google.gson.Gson.DEFAULT_COMPLEX_MAP_KEYS;
|
||||||
|
import static com.google.gson.Gson.DEFAULT_DATE_PATTERN;
|
||||||
import static com.google.gson.Gson.DEFAULT_ESCAPE_HTML;
|
import static com.google.gson.Gson.DEFAULT_ESCAPE_HTML;
|
||||||
import static com.google.gson.Gson.DEFAULT_JSON_NON_EXECUTABLE;
|
import static com.google.gson.Gson.DEFAULT_JSON_NON_EXECUTABLE;
|
||||||
import static com.google.gson.Gson.DEFAULT_LENIENT;
|
import static com.google.gson.Gson.DEFAULT_LENIENT;
|
||||||
|
import static com.google.gson.Gson.DEFAULT_NUMBER_TO_NUMBER_STRATEGY;
|
||||||
|
import static com.google.gson.Gson.DEFAULT_OBJECT_TO_NUMBER_STRATEGY;
|
||||||
import static com.google.gson.Gson.DEFAULT_PRETTY_PRINT;
|
import static com.google.gson.Gson.DEFAULT_PRETTY_PRINT;
|
||||||
import static com.google.gson.Gson.DEFAULT_SERIALIZE_NULLS;
|
import static com.google.gson.Gson.DEFAULT_SERIALIZE_NULLS;
|
||||||
import static com.google.gson.Gson.DEFAULT_SPECIALIZE_FLOAT_VALUES;
|
import static com.google.gson.Gson.DEFAULT_SPECIALIZE_FLOAT_VALUES;
|
||||||
@ -86,7 +89,7 @@ public final class GsonBuilder {
|
|||||||
/** tree-style hierarchy factories. These come after factories for backwards compatibility. */
|
/** tree-style hierarchy factories. These come after factories for backwards compatibility. */
|
||||||
private final List<TypeAdapterFactory> hierarchyFactories = new ArrayList<TypeAdapterFactory>();
|
private final List<TypeAdapterFactory> hierarchyFactories = new ArrayList<TypeAdapterFactory>();
|
||||||
private boolean serializeNulls = DEFAULT_SERIALIZE_NULLS;
|
private boolean serializeNulls = DEFAULT_SERIALIZE_NULLS;
|
||||||
private String datePattern;
|
private String datePattern = DEFAULT_DATE_PATTERN;
|
||||||
private int dateStyle = DateFormat.DEFAULT;
|
private int dateStyle = DateFormat.DEFAULT;
|
||||||
private int timeStyle = DateFormat.DEFAULT;
|
private int timeStyle = DateFormat.DEFAULT;
|
||||||
private boolean complexMapKeySerialization = DEFAULT_COMPLEX_MAP_KEYS;
|
private boolean complexMapKeySerialization = DEFAULT_COMPLEX_MAP_KEYS;
|
||||||
@ -96,8 +99,8 @@ public final class GsonBuilder {
|
|||||||
private boolean generateNonExecutableJson = DEFAULT_JSON_NON_EXECUTABLE;
|
private boolean generateNonExecutableJson = DEFAULT_JSON_NON_EXECUTABLE;
|
||||||
private boolean lenient = DEFAULT_LENIENT;
|
private boolean lenient = DEFAULT_LENIENT;
|
||||||
private boolean useJdkUnsafe = DEFAULT_USE_JDK_UNSAFE;
|
private boolean useJdkUnsafe = DEFAULT_USE_JDK_UNSAFE;
|
||||||
private ToNumberStrategy objectToNumberStrategy = ToNumberPolicy.DOUBLE;
|
private ToNumberStrategy objectToNumberStrategy = DEFAULT_OBJECT_TO_NUMBER_STRATEGY;
|
||||||
private ToNumberStrategy numberToNumberStrategy = ToNumberPolicy.LAZILY_PARSED_NUMBER;
|
private ToNumberStrategy numberToNumberStrategy = DEFAULT_NUMBER_TO_NUMBER_STRATEGY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a GsonBuilder instance that can be used to build Gson with various configuration
|
* Creates a GsonBuilder instance that can be used to build Gson with various configuration
|
||||||
|
Loading…
Reference in New Issue
Block a user