Create an "internals" package for classes that we do not want to share, but is needed across multiple pacakges.
As well, move non-Gson specific classes, such as Preconditions, to this new "internals" package.
This commit is contained in:
parent
657688ca79
commit
861e047a62
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
|
import com.google.gson.internal.Preconditions;
|
||||||
|
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
|
import com.google.gson.internal.Types;
|
||||||
|
|
||||||
import java.lang.reflect.ParameterizedType;
|
import java.lang.reflect.ParameterizedType;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
|
import com.google.gson.internal.Preconditions;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
|
import com.google.gson.internal.Preconditions;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,6 +16,11 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
|
import com.google.gson.internal.Cache;
|
||||||
|
import com.google.gson.internal.LruCache;
|
||||||
|
import com.google.gson.internal.Pair;
|
||||||
|
import com.google.gson.internal.Preconditions;
|
||||||
|
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
|
import com.google.gson.internal.Preconditions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapts the old "deprecated" FieldNamingStrategy to the new {@link FieldNamingStrategy2}
|
* Adapts the old "deprecated" FieldNamingStrategy to the new {@link FieldNamingStrategy2}
|
||||||
* type.
|
* type.
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
|
import com.google.gson.internal.Primitives;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonToken;
|
import com.google.gson.stream.JsonToken;
|
||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.google.gson.DefaultTypeAdapters.DefaultDateTypeAdapter;
|
import com.google.gson.DefaultTypeAdapters.DefaultDateTypeAdapter;
|
||||||
|
import com.google.gson.internal.Preconditions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Use this builder to construct a {@link Gson} instance when you need to set configuration
|
* <p>Use this builder to construct a {@link Gson} instance when you need to set configuration
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
|
import com.google.gson.internal.Types;
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,9 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
|
import com.google.gson.internal.Pair;
|
||||||
|
import com.google.gson.internal.Preconditions;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
|
import com.google.gson.internal.Preconditions;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
|
import com.google.gson.internal.Preconditions;
|
||||||
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
|
import com.google.gson.internal.Preconditions;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
|
@ -16,6 +16,9 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
|
import com.google.gson.internal.Pair;
|
||||||
|
import com.google.gson.internal.Primitives;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
|
import com.google.gson.internal.Preconditions;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,6 +16,10 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
|
import com.google.gson.internal.Pair;
|
||||||
|
import com.google.gson.internal.Preconditions;
|
||||||
|
import com.google.gson.internal.Types;
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
|
@ -168,7 +172,7 @@ final class JsonSerializationVisitor implements ObjectNavigator.Visitor {
|
||||||
/**
|
/**
|
||||||
* objTypePair.getObject() must not be null
|
* objTypePair.getObject() must not be null
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
@SuppressWarnings("unchecked")
|
||||||
private JsonElement findAndInvokeCustomSerializer(ObjectTypePair objTypePair) {
|
private JsonElement findAndInvokeCustomSerializer(ObjectTypePair objTypePair) {
|
||||||
Pair<JsonSerializer<?>,ObjectTypePair> pair = objTypePair.getMatchingHandler(serializers);
|
Pair<JsonSerializer<?>,ObjectTypePair> pair = objTypePair.getMatchingHandler(serializers);
|
||||||
if (pair == null) {
|
if (pair == null) {
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
|
import com.google.gson.internal.Types;
|
||||||
|
|
||||||
import java.lang.reflect.ParameterizedType;
|
import java.lang.reflect.ParameterizedType;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
|
|
@ -16,6 +16,9 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
|
import com.google.gson.internal.Types;
|
||||||
|
import com.google.gson.internal.UnsafeAllocator;
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
|
import com.google.gson.internal.Preconditions;
|
||||||
|
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
|
import com.google.gson.internal.Preconditions;
|
||||||
|
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
|
@ -16,6 +16,10 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
|
import com.google.gson.internal.Preconditions;
|
||||||
|
import com.google.gson.internal.Primitives;
|
||||||
|
import com.google.gson.internal.Types;
|
||||||
|
|
||||||
import java.lang.reflect.AccessibleObject;
|
import java.lang.reflect.AccessibleObject;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
|
import com.google.gson.internal.Preconditions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A factory class used to simplify {@link ObjectNavigator} creation.
|
* A factory class used to simplify {@link ObjectNavigator} creation.
|
||||||
* This object holds on to a reference of the {@link ExclusionStrategy}
|
* This object holds on to a reference of the {@link ExclusionStrategy}
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
*/
|
*/
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
|
import com.google.gson.internal.Pair;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,6 +16,9 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
|
import com.google.gson.internal.Pair;
|
||||||
|
import com.google.gson.internal.Types;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
|
@ -18,6 +18,7 @@ package com.google.gson;
|
||||||
|
|
||||||
import com.google.gson.annotations.Since;
|
import com.google.gson.annotations.Since;
|
||||||
import com.google.gson.annotations.Until;
|
import com.google.gson.annotations.Until;
|
||||||
|
import com.google.gson.internal.Preconditions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This strategy will exclude any files and/or class that are passed the
|
* This strategy will exclude any files and/or class that are passed the
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson.internal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines generic cache interface.
|
* Defines generic cache interface.
|
||||||
|
@ -22,7 +22,7 @@ package com.google.gson;
|
||||||
* @author Inderjeet Singh
|
* @author Inderjeet Singh
|
||||||
* @author Joel Leitch
|
* @author Joel Leitch
|
||||||
*/
|
*/
|
||||||
interface Cache<K, V> {
|
public interface Cache<K, V> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the new value object into the cache for the given key. If the key already
|
* Adds the new value object into the cache for the given key. If the key already
|
|
@ -14,7 +14,8 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson.internal;
|
||||||
|
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -27,12 +28,12 @@ import java.util.Map;
|
||||||
* @author Inderjeet Singh
|
* @author Inderjeet Singh
|
||||||
* @author Joel Leitch
|
* @author Joel Leitch
|
||||||
*/
|
*/
|
||||||
final class LruCache<K, V> extends LinkedHashMap<K, V> implements Cache<K, V> {
|
public final class LruCache<K, V> extends LinkedHashMap<K, V> implements Cache<K, V> {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private final int maxCapacity;
|
private final int maxCapacity;
|
||||||
|
|
||||||
LruCache(int maxCapacity) {
|
public LruCache(int maxCapacity) {
|
||||||
super(maxCapacity, 0.7F, true);
|
super(maxCapacity, 0.7F, true);
|
||||||
this.maxCapacity = maxCapacity;
|
this.maxCapacity = maxCapacity;
|
||||||
}
|
}
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson.internal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple object that holds onto a pair of object references, first and second.
|
* A simple object that holds onto a pair of object references, first and second.
|
||||||
|
@ -25,12 +25,11 @@ package com.google.gson;
|
||||||
* @param <FIRST>
|
* @param <FIRST>
|
||||||
* @param <SECOND>
|
* @param <SECOND>
|
||||||
*/
|
*/
|
||||||
final class Pair<FIRST, SECOND> {
|
public final class Pair<FIRST, SECOND> {
|
||||||
|
public final FIRST first;
|
||||||
|
public final SECOND second;
|
||||||
|
|
||||||
final FIRST first;
|
public Pair(FIRST first, SECOND second) {
|
||||||
final SECOND second;
|
|
||||||
|
|
||||||
Pair(FIRST first, SECOND second) {
|
|
||||||
this.first = first;
|
this.first = first;
|
||||||
this.second = second;
|
this.second = second;
|
||||||
}
|
}
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson.internal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple utility class used to check method Preconditions.
|
* A simple utility class used to check method Preconditions.
|
||||||
|
@ -29,7 +29,7 @@ package com.google.gson;
|
||||||
* @author Inderjeet Singh
|
* @author Inderjeet Singh
|
||||||
* @author Joel Leitch
|
* @author Joel Leitch
|
||||||
*/
|
*/
|
||||||
final class Preconditions {
|
public final class Preconditions {
|
||||||
public static <T> T checkNotNull(T obj) {
|
public static <T> T checkNotNull(T obj) {
|
||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
|
@ -14,7 +14,8 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson.internal;
|
||||||
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -27,14 +28,14 @@ import java.util.Map;
|
||||||
*
|
*
|
||||||
* @author Kevin Bourrillion
|
* @author Kevin Bourrillion
|
||||||
*/
|
*/
|
||||||
final class Primitives {
|
public final class Primitives {
|
||||||
private Primitives() {}
|
private Primitives() {}
|
||||||
|
|
||||||
/** A map from primitive types to their corresponding wrapper types. */
|
/** A map from primitive types to their corresponding wrapper types. */
|
||||||
public static final Map<Class<?>, Class<?>> PRIMITIVE_TO_WRAPPER_TYPE;
|
private static final Map<Class<?>, Class<?>> PRIMITIVE_TO_WRAPPER_TYPE;
|
||||||
|
|
||||||
/** A map from wrapper types to their corresponding primitive types. */
|
/** A map from wrapper types to their corresponding primitive types. */
|
||||||
public static final Map<Class<?>, Class<?>> WRAPPER_TO_PRIMITIVE_TYPE;
|
private static final Map<Class<?>, Class<?>> WRAPPER_TO_PRIMITIVE_TYPE;
|
||||||
|
|
||||||
// Sad that we can't use a BiMap. :(
|
// Sad that we can't use a BiMap. :(
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson.internal;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
|
@ -274,7 +274,7 @@ public final class Types {
|
||||||
* Returns true if this type is an array.
|
* Returns true if this type is an array.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
static boolean isArray(Type type) {
|
public static boolean isArray(Type type) {
|
||||||
return type instanceof GenericArrayType
|
return type instanceof GenericArrayType
|
||||||
|| (type instanceof Class && ((Class<?>) type).isArray());
|
|| (type instanceof Class && ((Class<?>) type).isArray());
|
||||||
}
|
}
|
||||||
|
@ -283,7 +283,7 @@ public final class Types {
|
||||||
* 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.
|
||||||
*/
|
*/
|
||||||
static Type getArrayComponentType(Type array) {
|
public static Type getArrayComponentType(Type array) {
|
||||||
return array instanceof GenericArrayType
|
return array instanceof GenericArrayType
|
||||||
? ((GenericArrayType) array).getGenericComponentType()
|
? ((GenericArrayType) array).getGenericComponentType()
|
||||||
: ((Class<?>) array).getComponentType();
|
: ((Class<?>) array).getComponentType();
|
||||||
|
@ -293,7 +293,7 @@ public final class Types {
|
||||||
* Returns the element type of this collection type.
|
* Returns the element type of this collection type.
|
||||||
* @throws IllegalArgumentException if this type is not a collection.
|
* @throws IllegalArgumentException if this type is not a collection.
|
||||||
*/
|
*/
|
||||||
static Type getCollectionElementType(Type context, Class<?> contextRawType) {
|
public static Type getCollectionElementType(Type context, Class<?> contextRawType) {
|
||||||
Type collectionType = getSupertype(context, contextRawType, Collection.class);
|
Type collectionType = getSupertype(context, contextRawType, Collection.class);
|
||||||
return ((ParameterizedType) collectionType).getActualTypeArguments()[0];
|
return ((ParameterizedType) collectionType).getActualTypeArguments()[0];
|
||||||
}
|
}
|
||||||
|
@ -302,7 +302,7 @@ public final class Types {
|
||||||
* Returns a two element array containing this map's key and value types in
|
* Returns a two element array containing this map's key and value types in
|
||||||
* positions 0 and 1 respectively.
|
* positions 0 and 1 respectively.
|
||||||
*/
|
*/
|
||||||
static Type[] getMapKeyAndValueTypes(Type context, Class<?> contextRawType) {
|
public static Type[] getMapKeyAndValueTypes(Type context, Class<?> contextRawType) {
|
||||||
/*
|
/*
|
||||||
* Work around a problem with the declaration of java.util.Properties. That
|
* Work around a problem with the declaration of java.util.Properties. That
|
||||||
* class should extend Hashtable<String, String>, but it's declared to
|
* class should extend Hashtable<String, String>, but it's declared to
|
||||||
|
@ -318,7 +318,7 @@ public final class Types {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
static Type resolve(Type context, Class<?> contextRawType, Type toResolve) {
|
public static Type resolve(Type context, Class<?> contextRawType, Type toResolve) {
|
||||||
// this implementation is made a little more complicated in an attempt to avoid object-creation
|
// this implementation is made a little more complicated in an attempt to avoid object-creation
|
||||||
while (true) {
|
while (true) {
|
||||||
if (toResolve instanceof TypeVariable) {
|
if (toResolve instanceof TypeVariable) {
|
||||||
|
@ -390,7 +390,7 @@ public final class Types {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@SuppressWarnings("unchecked")
|
||||||
static Type resolveTypeVariable(Type context, Class<?> contextRawType, TypeVariable unknown) {
|
static Type resolveTypeVariable(Type context, Class<?> contextRawType, TypeVariable unknown) {
|
||||||
Class<?> declaredByRaw = declaringClassOf(unknown);
|
Class<?> declaredByRaw = declaringClassOf(unknown);
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson.internal;
|
||||||
|
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectStreamClass;
|
import java.io.ObjectStreamClass;
|
||||||
|
@ -27,7 +27,7 @@ import java.lang.reflect.Method;
|
||||||
* @author Joel Leitch
|
* @author Joel Leitch
|
||||||
* @author Jesse Wilson
|
* @author Jesse Wilson
|
||||||
*/
|
*/
|
||||||
abstract class UnsafeAllocator {
|
public abstract class UnsafeAllocator {
|
||||||
public abstract <T> T newInstance(Class<T> c) throws Exception;
|
public abstract <T> T newInstance(Class<T> c) throws Exception;
|
||||||
|
|
||||||
public static UnsafeAllocator create() {
|
public static UnsafeAllocator create() {
|
|
@ -16,7 +16,8 @@
|
||||||
|
|
||||||
package com.google.gson.reflect;
|
package com.google.gson.reflect;
|
||||||
|
|
||||||
import com.google.gson.Types;
|
import com.google.gson.internal.Types;
|
||||||
|
|
||||||
import java.lang.reflect.GenericArrayType;
|
import java.lang.reflect.GenericArrayType;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.ParameterizedType;
|
import java.lang.reflect.ParameterizedType;
|
||||||
|
@ -35,11 +36,11 @@ import java.util.Map;
|
||||||
* create an empty anonymous inner class:
|
* create an empty anonymous inner class:
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* {@code TypeLiteral<List<String>> list = new TypeToken<List<String>>() {};}
|
* {@code TypeToken<List<String>> list = new TypeToken<List<String>>() {};}
|
||||||
*
|
*
|
||||||
* <p>This syntax cannot be used to create type literals that have wildcard
|
* <p>This syntax cannot be used to create type literals that have wildcard
|
||||||
* parameters, such as {@code Class<?>} or {@code List<? extends CharSequence>}.
|
* parameters, such as {@code Class<?>} or {@code List<? extends CharSequence>}.
|
||||||
* Such type literals must be constructed programatically, either by {@link
|
* Such type tokens must be constructed programatically, either by {@link
|
||||||
* Method#getGenericReturnType extracting types from members} or by using the
|
* Method#getGenericReturnType extracting types from members} or by using the
|
||||||
* {@link Types} factory class.
|
* {@link Types} factory class.
|
||||||
*
|
*
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
|
import com.google.gson.internal.Types;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
|
@ -16,6 +16,9 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
|
import com.google.gson.internal.Cache;
|
||||||
|
import com.google.gson.internal.LruCache;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
import com.google.gson.MemoryRefStack;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
|
import com.google.gson.internal.Types;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
|
@ -16,6 +16,9 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
|
import com.google.gson.internal.Primitives;
|
||||||
|
import com.google.gson.internal.Types;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.ParameterizedType;
|
import java.lang.reflect.ParameterizedType;
|
||||||
|
|
|
@ -21,7 +21,7 @@ import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.Primitives;
|
import com.google.gson.internal.Primitives;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles type conversion from some object to some primitive (or primitive
|
* Handles type conversion from some object to some primitive (or primitive
|
||||||
|
|
|
@ -19,8 +19,6 @@ package com.google.gson.functional;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.InstanceCreator;
|
import com.google.gson.InstanceCreator;
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.common.TestTypes.BagOfPrimitives;
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
|
@ -133,7 +133,7 @@ public final class TypeHierarchyAdapterTest extends TestCase {
|
||||||
|
|
||||||
public void testRegisterSubTypeFirstNotAllowed() {
|
public void testRegisterSubTypeFirstNotAllowed() {
|
||||||
try {
|
try {
|
||||||
Gson gson = new GsonBuilder()
|
new GsonBuilder()
|
||||||
.registerTypeHierarchyAdapter(Manager.class, new ManagerAdapter())
|
.registerTypeHierarchyAdapter(Manager.class, new ManagerAdapter())
|
||||||
.registerTypeHierarchyAdapter(Employee.class, new EmployeeAdapter())
|
.registerTypeHierarchyAdapter(Employee.class, new EmployeeAdapter())
|
||||||
.create();
|
.create();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user