Remove dead code and fold contents of single-member helper classes into their clients.
This commit is contained in:
parent
e9521471aa
commit
f777a192ee
@ -116,7 +116,7 @@ public final class GsonBuilder {
|
|||||||
serializeExclusionStrategies.add(Gson.DEFAULT_SYNTHETIC_FIELD_EXCLUSION_STRATEGY);
|
serializeExclusionStrategies.add(Gson.DEFAULT_SYNTHETIC_FIELD_EXCLUSION_STRATEGY);
|
||||||
|
|
||||||
// setup default values
|
// setup default values
|
||||||
ignoreVersionsAfter = VersionConstants.IGNORE_VERSIONS;
|
ignoreVersionsAfter = VersionExclusionStrategy.IGNORE_VERSIONS;
|
||||||
serializeInnerClasses = true;
|
serializeInnerClasses = true;
|
||||||
prettyPrinting = false;
|
prettyPrinting = false;
|
||||||
escapeHtmlChars = true;
|
escapeHtmlChars = true;
|
||||||
@ -650,7 +650,7 @@ public final class GsonBuilder {
|
|||||||
deserializationStrategies.add(innerClassExclusionStrategy);
|
deserializationStrategies.add(innerClassExclusionStrategy);
|
||||||
serializationStrategies.add(innerClassExclusionStrategy);
|
serializationStrategies.add(innerClassExclusionStrategy);
|
||||||
}
|
}
|
||||||
if (ignoreVersionsAfter != VersionConstants.IGNORE_VERSIONS) {
|
if (ignoreVersionsAfter != VersionExclusionStrategy.IGNORE_VERSIONS) {
|
||||||
VersionExclusionStrategy versionExclusionStrategy =
|
VersionExclusionStrategy versionExclusionStrategy =
|
||||||
new VersionExclusionStrategy(ignoreVersionsAfter);
|
new VersionExclusionStrategy(ignoreVersionsAfter);
|
||||||
deserializationStrategies.add(versionExclusionStrategy);
|
deserializationStrategies.add(versionExclusionStrategy);
|
||||||
|
@ -31,7 +31,6 @@ import java.lang.reflect.Type;
|
|||||||
* @author Joel Leitch
|
* @author Joel Leitch
|
||||||
*/
|
*/
|
||||||
final class JsonDeserializerExceptionWrapper<T> implements JsonDeserializer<T> {
|
final class JsonDeserializerExceptionWrapper<T> implements JsonDeserializer<T> {
|
||||||
|
|
||||||
private final JsonDeserializer<T> delegate;
|
private final JsonDeserializer<T> delegate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,7 +23,6 @@ package com.google.gson;
|
|||||||
* @author Joel Leitch
|
* @author Joel Leitch
|
||||||
*/
|
*/
|
||||||
public final class JsonIOException extends JsonParseException {
|
public final class JsonIOException extends JsonParseException {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public JsonIOException(String msg) {
|
public JsonIOException(String msg) {
|
||||||
|
@ -50,7 +50,6 @@ import com.google.gson.stream.MalformedJsonException;
|
|||||||
* @since 1.4
|
* @since 1.4
|
||||||
*/
|
*/
|
||||||
public final class JsonStreamParser implements Iterator<JsonElement> {
|
public final class JsonStreamParser implements Iterator<JsonElement> {
|
||||||
|
|
||||||
private final JsonReader parser;
|
private final JsonReader parser;
|
||||||
private final Object lock;
|
private final Object lock;
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ final class ModifyFirstLetterNamingPolicy extends RecursiveFieldNamingPolicy {
|
|||||||
|
|
||||||
public enum LetterModifier {
|
public enum LetterModifier {
|
||||||
UPPER,
|
UPPER,
|
||||||
LOWER;
|
LOWER
|
||||||
}
|
}
|
||||||
|
|
||||||
private final LetterModifier letterModifier;
|
private final LetterModifier letterModifier;
|
||||||
|
@ -40,5 +40,4 @@ final class SyntheticFieldExclusionStrategy implements ExclusionStrategy {
|
|||||||
public boolean shouldSkipField(FieldAttributes f) {
|
public boolean shouldSkipField(FieldAttributes f) {
|
||||||
return skipSyntheticFields && f.isSynthetic();
|
return skipSyntheticFields && f.isSynthetic();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,6 @@ package com.google.gson;
|
|||||||
* @author Joel Leitch
|
* @author Joel Leitch
|
||||||
*/
|
*/
|
||||||
final class UpperCamelCaseSeparatorNamingPolicy extends CompositionFieldNamingPolicy {
|
final class UpperCamelCaseSeparatorNamingPolicy extends CompositionFieldNamingPolicy {
|
||||||
|
|
||||||
public UpperCamelCaseSeparatorNamingPolicy(String separatorString) {
|
public UpperCamelCaseSeparatorNamingPolicy(String separatorString) {
|
||||||
super(new CamelCaseSeparatorNamingPolicy(separatorString),
|
super(new CamelCaseSeparatorNamingPolicy(separatorString),
|
||||||
new ModifyFirstLetterNamingPolicy(ModifyFirstLetterNamingPolicy.LetterModifier.UPPER));
|
new ModifyFirstLetterNamingPolicy(ModifyFirstLetterNamingPolicy.LetterModifier.UPPER));
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2008 Google Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.google.gson;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class contain all constants for versioning support.
|
|
||||||
*
|
|
||||||
* @author Joel Leitch
|
|
||||||
*/
|
|
||||||
final class VersionConstants {
|
|
||||||
// Prevent instantiation
|
|
||||||
private VersionConstants() { }
|
|
||||||
|
|
||||||
static final double IGNORE_VERSIONS = -1D;
|
|
||||||
}
|
|
@ -27,6 +27,7 @@ import com.google.gson.internal.$Gson$Preconditions;
|
|||||||
* @author Joel Leitch
|
* @author Joel Leitch
|
||||||
*/
|
*/
|
||||||
final class VersionExclusionStrategy implements ExclusionStrategy {
|
final class VersionExclusionStrategy implements ExclusionStrategy {
|
||||||
|
static final double IGNORE_VERSIONS = -1D;
|
||||||
private final double version;
|
private final double version;
|
||||||
|
|
||||||
VersionExclusionStrategy(double version) {
|
VersionExclusionStrategy(double version) {
|
||||||
|
@ -42,10 +42,4 @@ public final class $Gson$Preconditions {
|
|||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void checkState(boolean condition) {
|
|
||||||
if (!condition) {
|
|
||||||
throw new IllegalStateException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -269,14 +269,6 @@ public final class $Gson$Types {
|
|||||||
$Gson$Types.getGenericSupertype(context, contextRawType, supertype));
|
$Gson$Types.getGenericSupertype(context, contextRawType, supertype));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if this type is an array.
|
|
||||||
*/
|
|
||||||
public static boolean isArray(Type type) {
|
|
||||||
return type instanceof GenericArrayType
|
|
||||||
|| (type instanceof Class && ((Class<?>) type).isArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the component type of this array type.
|
* Returns the component type of this array type.
|
||||||
* @throws ClassCastException if this type is not an array.
|
* @throws ClassCastException if this type is not an array.
|
||||||
|
@ -45,10 +45,8 @@ public final class ArrayTypeAdapter<E> extends TypeAdapter<Object> {
|
|||||||
|
|
||||||
Type componentType = $Gson$Types.getArrayComponentType(type);
|
Type componentType = $Gson$Types.getArrayComponentType(type);
|
||||||
TypeAdapter<?> componentTypeAdapter = context.getAdapter(TypeToken.get(componentType));
|
TypeAdapter<?> componentTypeAdapter = context.getAdapter(TypeToken.get(componentType));
|
||||||
// create() doesn't define a type parameter
|
return new ArrayTypeAdapter(
|
||||||
TypeAdapter<T> result = new ArrayTypeAdapter(
|
|
||||||
context, componentTypeAdapter, $Gson$Types.getRawType(componentType));
|
context, componentTypeAdapter, $Gson$Types.getRawType(componentType));
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -84,13 +82,13 @@ public final class ArrayTypeAdapter<E> extends TypeAdapter<Object> {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override public void write(JsonWriter writer, Object array) throws IOException {
|
@Override public void write(JsonWriter writer, Object array) throws IOException {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
writer.nullValue(); // TODO: better policy here?
|
writer.nullValue();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.beginArray();
|
writer.beginArray();
|
||||||
for (int i = 0, length = Array.getLength(array); i < length; i++) {
|
for (int i = 0, length = Array.getLength(array); i < length; i++) {
|
||||||
final E value = (E) Array.get(array, i);
|
E value = (E) Array.get(array, i);
|
||||||
componentTypeAdapter.write(writer, value);
|
componentTypeAdapter.write(writer, value);
|
||||||
}
|
}
|
||||||
writer.endArray();
|
writer.endArray();
|
||||||
|
@ -48,10 +48,7 @@ public final class ExcludedTypeAdapterFactory implements TypeAdapter.Factory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new TypeAdapter<T>() {
|
return new TypeAdapter<T>() {
|
||||||
/**
|
/** The delegate is lazily created because it may not be needed, and creating it may fail. */
|
||||||
* The delegate is lazily created because it may not be needed, and
|
|
||||||
* creating it may fail.
|
|
||||||
*/
|
|
||||||
private TypeAdapter<T> delegate;
|
private TypeAdapter<T> delegate;
|
||||||
|
|
||||||
@Override public T read(JsonReader reader) throws IOException {
|
@Override public T read(JsonReader reader) throws IOException {
|
||||||
|
@ -195,7 +195,7 @@ public final class MapTypeAdapterFactory implements TypeAdapter.Factory {
|
|||||||
|
|
||||||
public void write(JsonWriter writer, Map<K, V> map) throws IOException {
|
public void write(JsonWriter writer, Map<K, V> map) throws IOException {
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
writer.nullValue(); // TODO: better policy here?
|
writer.nullValue();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ public final class ObjectTypeAdapter extends TypeAdapter<Object> {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override public void write(JsonWriter writer, Object value) throws IOException {
|
@Override public void write(JsonWriter writer, Object value) throws IOException {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
writer.nullValue(); // TODO: better policy here?
|
writer.nullValue();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2011 Google Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package com.google.gson.internal.bind;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.lang.reflect.TypeVariable;
|
|
||||||
|
|
||||||
final class Reflection {
|
|
||||||
/**
|
|
||||||
* Finds a compatible runtime type if it is more specific
|
|
||||||
*/
|
|
||||||
public static Type getRuntimeTypeIfMoreSpecific(Type type, Object value) {
|
|
||||||
if (value != null
|
|
||||||
&& (type == Object.class || type instanceof TypeVariable<?> || type instanceof Class<?>)) {
|
|
||||||
type = value.getClass();
|
|
||||||
}
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,109 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2011 Google Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.google.gson.internal.bind;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.TypeAdapter;
|
|
||||||
import com.google.gson.internal.$Gson$Types;
|
|
||||||
import com.google.gson.internal.ConstructorConstructor;
|
|
||||||
import com.google.gson.internal.ObjectConstructor;
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
import com.google.gson.stream.JsonReader;
|
|
||||||
import com.google.gson.stream.JsonToken;
|
|
||||||
import com.google.gson.stream.JsonWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.ParameterizedType;
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adapt a map whose keys are strings.
|
|
||||||
*/
|
|
||||||
public final class StringToValueMapTypeAdapterFactory implements TypeAdapter.Factory {
|
|
||||||
private final ConstructorConstructor constructorConstructor;
|
|
||||||
|
|
||||||
public StringToValueMapTypeAdapterFactory(ConstructorConstructor constructorConstructor) {
|
|
||||||
this.constructorConstructor = constructorConstructor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> TypeAdapter<T> create(Gson context, TypeToken<T> typeToken) {
|
|
||||||
Type type = typeToken.getType();
|
|
||||||
if (!(type instanceof ParameterizedType)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Class<? super T> rawType = typeToken.getRawType();
|
|
||||||
if (!Map.class.isAssignableFrom(rawType)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Type[] keyAndValueTypes = $Gson$Types.getMapKeyAndValueTypes(type, rawType);
|
|
||||||
if (keyAndValueTypes[0] != String.class) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
TypeAdapter<?> valueAdapter = context.getAdapter(TypeToken.get(keyAndValueTypes[1]));
|
|
||||||
|
|
||||||
ObjectConstructor<?> constructor = constructorConstructor.getConstructor(typeToken);
|
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
|
||||||
// we don't define a type parameter for the key or value types
|
|
||||||
TypeAdapter<T> result = new Adapter(valueAdapter, constructor);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final class Adapter<V> extends TypeAdapter<Map<String, V>> {
|
|
||||||
private final TypeAdapter<V> valueTypeAdapter;
|
|
||||||
private final ObjectConstructor<? extends Map<String, V>> constructor;
|
|
||||||
|
|
||||||
public Adapter(TypeAdapter<V> valueTypeAdapter,
|
|
||||||
ObjectConstructor<? extends Map<String, V>> constructor) {
|
|
||||||
this.valueTypeAdapter = valueTypeAdapter;
|
|
||||||
this.constructor = constructor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, V> read(JsonReader reader) throws IOException {
|
|
||||||
if (reader.peek() == JsonToken.NULL) {
|
|
||||||
reader.nextNull();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, V> map = constructor.construct();
|
|
||||||
reader.beginObject();
|
|
||||||
while (reader.hasNext()) {
|
|
||||||
String key = reader.nextName();
|
|
||||||
V value = valueTypeAdapter.read(reader);
|
|
||||||
map.put(key, value);
|
|
||||||
}
|
|
||||||
reader.endObject();
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void write(JsonWriter writer, Map<String, V> map) throws IOException {
|
|
||||||
if (map == null) {
|
|
||||||
writer.nullValue(); // TODO: better policy here?
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.beginObject();
|
|
||||||
for (Map.Entry<String, V> entry : map.entrySet()) {
|
|
||||||
writer.name(entry.getKey());
|
|
||||||
valueTypeAdapter.write(writer, entry.getValue());
|
|
||||||
}
|
|
||||||
writer.endObject();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -22,9 +22,9 @@ import com.google.gson.stream.JsonReader;
|
|||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
import java.lang.reflect.TypeVariable;
|
||||||
|
|
||||||
final class TypeAdapterRuntimeTypeWrapper<T> extends TypeAdapter<T> {
|
final class TypeAdapterRuntimeTypeWrapper<T> extends TypeAdapter<T> {
|
||||||
|
|
||||||
private final Gson context;
|
private final Gson context;
|
||||||
private final TypeAdapter<T> delegate;
|
private final TypeAdapter<T> delegate;
|
||||||
private final Type type;
|
private final Type type;
|
||||||
@ -50,7 +50,7 @@ final class TypeAdapterRuntimeTypeWrapper<T> extends TypeAdapter<T> {
|
|||||||
// Fourth preference: reflective type adapter for the declared type
|
// Fourth preference: reflective type adapter for the declared type
|
||||||
|
|
||||||
TypeAdapter chosen = delegate;
|
TypeAdapter chosen = delegate;
|
||||||
Type runtimeType = Reflection.getRuntimeTypeIfMoreSpecific(type, value);
|
Type runtimeType = getRuntimeTypeIfMoreSpecific(type, value);
|
||||||
if (runtimeType != type) {
|
if (runtimeType != type) {
|
||||||
TypeAdapter runtimeTypeAdapter = context.getAdapter(TypeToken.get(runtimeType));
|
TypeAdapter runtimeTypeAdapter = context.getAdapter(TypeToken.get(runtimeType));
|
||||||
if (!(runtimeTypeAdapter instanceof ReflectiveTypeAdapterFactory.Adapter)) {
|
if (!(runtimeTypeAdapter instanceof ReflectiveTypeAdapterFactory.Adapter)) {
|
||||||
@ -67,4 +67,15 @@ final class TypeAdapterRuntimeTypeWrapper<T> extends TypeAdapter<T> {
|
|||||||
}
|
}
|
||||||
chosen.write(writer, value);
|
chosen.write(writer, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds a compatible runtime type if it is more specific
|
||||||
|
*/
|
||||||
|
private Type getRuntimeTypeIfMoreSpecific(Type type, Object value) {
|
||||||
|
if (value != null
|
||||||
|
&& (type == Object.class || type instanceof TypeVariable<?> || type instanceof Class<?>)) {
|
||||||
|
type = value.getClass();
|
||||||
|
}
|
||||||
|
return type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -239,9 +239,6 @@ public final class TypeAdapters {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final TypeAdapter.Factory LONG_FACTORY
|
|
||||||
= newFactory(long.class, Long.class, LONG);
|
|
||||||
|
|
||||||
public static final TypeAdapter<Number> FLOAT = new TypeAdapter<Number>() {
|
public static final TypeAdapter<Number> FLOAT = new TypeAdapter<Number>() {
|
||||||
@Override
|
@Override
|
||||||
public Number read(JsonReader reader) throws IOException {
|
public Number read(JsonReader reader) throws IOException {
|
||||||
@ -257,9 +254,6 @@ public final class TypeAdapters {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final TypeAdapter.Factory FLOAT_FACTORY
|
|
||||||
= newFactory(float.class, Float.class, FLOAT);
|
|
||||||
|
|
||||||
public static final TypeAdapter<Number> DOUBLE = new TypeAdapter<Number>() {
|
public static final TypeAdapter<Number> DOUBLE = new TypeAdapter<Number>() {
|
||||||
@Override
|
@Override
|
||||||
public Number read(JsonReader reader) throws IOException {
|
public Number read(JsonReader reader) throws IOException {
|
||||||
@ -275,9 +269,6 @@ public final class TypeAdapters {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final TypeAdapter.Factory DOUBLE_FACTORY
|
|
||||||
= newFactory(double.class, Double.class, DOUBLE);
|
|
||||||
|
|
||||||
public static final TypeAdapter<Number> NUMBER = new TypeAdapter<Number>() {
|
public static final TypeAdapter<Number> NUMBER = new TypeAdapter<Number>() {
|
||||||
@Override
|
@Override
|
||||||
public Number read(JsonReader reader) throws IOException {
|
public Number read(JsonReader reader) throws IOException {
|
||||||
@ -663,13 +654,13 @@ public final class TypeAdapters {
|
|||||||
reader.nextNull();
|
reader.nextNull();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return (T) Enum.valueOf((Class<T>) classOfT, reader.nextString());
|
return Enum.valueOf(classOfT, reader.nextString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(JsonWriter writer, T value) throws IOException {
|
public void write(JsonWriter writer, T value) throws IOException {
|
||||||
writer.value(value == null ? null : value.name());
|
writer.value(value == null ? null : value.name());
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
public static final TypeAdapter.Factory ENUM_FACTORY = newEnumTypeHierarchyFactory(Enum.class);
|
public static final TypeAdapter.Factory ENUM_FACTORY = newEnumTypeHierarchyFactory(Enum.class);
|
||||||
|
|
||||||
@ -749,5 +740,4 @@ public final class TypeAdapters {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,6 @@ import java.util.Map;
|
|||||||
* @author Jesse Wilson
|
* @author Jesse Wilson
|
||||||
*/
|
*/
|
||||||
public class TypeToken<T> {
|
public class TypeToken<T> {
|
||||||
|
|
||||||
final Class<? super T> rawType;
|
final Class<? super T> rawType;
|
||||||
final Type type;
|
final Type type;
|
||||||
final int hashCode;
|
final int hashCode;
|
||||||
|
Loading…
Reference in New Issue
Block a user