Renamed $Preconditions to $Gson$Preconditions and $Types to $Gson$Types.

Marked the two private classes in $Types as final.
This commit is contained in:
Inderjeet Singh 2011-04-06 00:26:57 +00:00
parent 8d3bfc0f47
commit c8bd121db2
29 changed files with 106 additions and 106 deletions

View File

@ -16,7 +16,7 @@
package com.google.gson;
import com.google.gson.internal.$Preconditions;
import com.google.gson.internal.$Gson$Preconditions;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
@ -53,8 +53,8 @@ final class CamelCaseSeparatorNamingPolicy extends RecursiveFieldNamingPolicy {
* is null or empty.
*/
public CamelCaseSeparatorNamingPolicy(String separatorString) {
$Preconditions.checkNotNull(separatorString);
$Preconditions.checkArgument(!"".equals(separatorString));
$Gson$Preconditions.checkNotNull(separatorString);
$Gson$Preconditions.checkArgument(!"".equals(separatorString));
this.separatorString = separatorString;
}

View File

@ -16,7 +16,7 @@
package com.google.gson;
import com.google.gson.internal.$Types;
import com.google.gson.internal.$Gson$Types;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.math.BigDecimal;
@ -631,8 +631,8 @@ final class DefaultTypeAdapters {
JsonArray array = new JsonArray();
Type childGenericType = null;
if (typeOfSrc instanceof ParameterizedType) {
Class<?> rawTypeOfSrc = $Types.getRawType(typeOfSrc);
childGenericType = $Types.getCollectionElementType(typeOfSrc, rawTypeOfSrc);
Class<?> rawTypeOfSrc = $Gson$Types.getRawType(typeOfSrc);
childGenericType = $Gson$Types.getCollectionElementType(typeOfSrc, rawTypeOfSrc);
}
for (Object child : src) {
if (child == null) {
@ -655,7 +655,7 @@ final class DefaultTypeAdapters {
// Use ObjectConstructor to create instance instead of hard-coding a specific type.
// This handles cases where users are using their own subclass of Collection.
Collection collection = constructCollectionType(typeOfT, context);
Type childType = $Types.getCollectionElementType(typeOfT, $Types.getRawType(typeOfT));
Type childType = $Gson$Types.getCollectionElementType(typeOfT, $Gson$Types.getRawType(typeOfT));
for (JsonElement childElement : json.getAsJsonArray()) {
if (childElement == null || childElement.isJsonNull()) {
collection.add(null);
@ -1043,7 +1043,7 @@ final class DefaultTypeAdapters {
}
public T createInstance(Type type) {
Class<?> rawType = $Types.getRawType(type);
Class<?> rawType = $Gson$Types.getRawType(type);
try {
T specificInstance = (T) allocator.newInstance(rawType);
return (specificInstance == null)

View File

@ -16,7 +16,7 @@
package com.google.gson;
import com.google.gson.internal.$Preconditions;
import com.google.gson.internal.$Gson$Preconditions;
import java.io.IOException;
@ -50,7 +50,7 @@ class DelegatingJsonElementVisitor implements JsonElementVisitor {
private final JsonElementVisitor delegate;
protected DelegatingJsonElementVisitor(JsonElementVisitor delegate) {
this.delegate = $Preconditions.checkNotNull(delegate);
this.delegate = $Gson$Preconditions.checkNotNull(delegate);
}
public void endArray(JsonArray array) throws IOException {

View File

@ -16,7 +16,7 @@
package com.google.gson;
import com.google.gson.internal.$Preconditions;
import com.google.gson.internal.$Gson$Preconditions;
import java.util.Collection;
@ -30,7 +30,7 @@ final class DisjunctionExclusionStrategy implements ExclusionStrategy {
private final Collection<ExclusionStrategy> strategies;
DisjunctionExclusionStrategy(Collection<ExclusionStrategy> strategies) {
this.strategies = $Preconditions.checkNotNull(strategies);
this.strategies = $Gson$Preconditions.checkNotNull(strategies);
}
public boolean shouldSkipField(FieldAttributes f) {

View File

@ -16,8 +16,8 @@
package com.google.gson;
import com.google.gson.internal.$Preconditions;
import com.google.gson.internal.$Types;
import com.google.gson.internal.$Gson$Preconditions;
import com.google.gson.internal.$Gson$Types;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
@ -56,7 +56,7 @@ public final class FieldAttributes {
private Collection<Annotation> annotations;
FieldAttributes(Class<?> declaringClazz, Field f) {
this.declaringClazz = $Preconditions.checkNotNull(declaringClazz);
this.declaringClazz = $Gson$Preconditions.checkNotNull(declaringClazz);
this.name = f.getName();
this.declaredType = f.getType();
this.isSynthetic = f.isSynthetic();
@ -72,7 +72,7 @@ public final class FieldAttributes {
* @param declaringType The type in which the field is declared
*/
FieldAttributes(Class<?> declaringClazz, Field f, Type declaringType) {
this.declaringClazz = $Preconditions.checkNotNull(declaringClazz);
this.declaringClazz = $Gson$Preconditions.checkNotNull(declaringClazz);
this.name = f.getName();
this.declaredType = f.getType();
this.isSynthetic = f.isSynthetic();
@ -255,11 +255,11 @@ public final class FieldAttributes {
* @return the type information for the field
*/
static Type getTypeInfoForField(Field f, Type typeDefiningF) {
Class<?> rawType = $Types.getRawType(typeDefiningF);
Class<?> rawType = $Gson$Types.getRawType(typeDefiningF);
if (!f.getDeclaringClass().isAssignableFrom(rawType)) {
// this field is unrelated to the type; the user probably omitted type information
return f.getGenericType();
}
return $Types.resolve(typeDefiningF, rawType, f.getGenericType());
return $Gson$Types.resolve(typeDefiningF, rawType, f.getGenericType());
}
}

View File

@ -16,7 +16,7 @@
package com.google.gson;
import com.google.gson.internal.$Preconditions;
import com.google.gson.internal.$Gson$Preconditions;
/**
* Adapts the old "deprecated" FieldNamingStrategy to the new {@link FieldNamingStrategy2}
@ -30,7 +30,7 @@ final class FieldNamingStrategy2Adapter implements FieldNamingStrategy2 {
private final FieldNamingStrategy adaptee;
public FieldNamingStrategy2Adapter(FieldNamingStrategy adaptee) {
this.adaptee = $Preconditions.checkNotNull(adaptee);
this.adaptee = $Gson$Preconditions.checkNotNull(adaptee);
}
public String translateName(FieldAttributes f) {

View File

@ -17,7 +17,7 @@
package com.google.gson;
import com.google.gson.DefaultTypeAdapters.DefaultDateTypeAdapter;
import com.google.gson.internal.$Preconditions;
import com.google.gson.internal.$Gson$Preconditions;
import java.lang.reflect.Type;
import java.sql.Timestamp;
@ -482,7 +482,7 @@ public final class GsonBuilder {
* @return a reference to this {@code GsonBuilder} object to fulfill the "Builder" pattern
*/
public GsonBuilder registerTypeAdapter(Type type, Object typeAdapter) {
$Preconditions.checkArgument(typeAdapter instanceof JsonSerializer<?>
$Gson$Preconditions.checkArgument(typeAdapter instanceof JsonSerializer<?>
|| typeAdapter instanceof JsonDeserializer<?> || typeAdapter instanceof InstanceCreator<?>);
if (typeAdapter instanceof InstanceCreator<?>) {
registerInstanceCreator(type, (InstanceCreator<?>) typeAdapter);
@ -561,7 +561,7 @@ public final class GsonBuilder {
* @since 1.7
*/
public GsonBuilder registerTypeHierarchyAdapter(Class<?> baseType, Object typeAdapter) {
$Preconditions.checkArgument(typeAdapter instanceof JsonSerializer<?>
$Gson$Preconditions.checkArgument(typeAdapter instanceof JsonSerializer<?>
|| typeAdapter instanceof JsonDeserializer<?> || typeAdapter instanceof InstanceCreator<?>);
if (typeAdapter instanceof InstanceCreator<?>) {
registerInstanceCreatorForTypeHierarchy(baseType, (InstanceCreator<?>) typeAdapter);

View File

@ -16,7 +16,7 @@
package com.google.gson;
import com.google.gson.internal.$Types;
import com.google.gson.internal.$Gson$Types;
import java.lang.reflect.Array;
import java.lang.reflect.Type;
@ -45,14 +45,14 @@ final class JsonArrayDeserializationVisitor<T> extends JsonDeserializationVisito
throw new JsonParseException("Expecting array found: " + json);
}
JsonArray jsonArray = json.getAsJsonArray();
if ($Types.isArray(targetType)) {
if ($Gson$Types.isArray(targetType)) {
// We know that we are getting back an array of the required type, so
// this typecasting is safe.
return (T) objectConstructor.constructArray($Types.getArrayComponentType(targetType),
return (T) objectConstructor.constructArray($Gson$Types.getArrayComponentType(targetType),
jsonArray.size());
}
// is a collection
return (T) objectConstructor.construct($Types.getRawType(targetType));
return (T) objectConstructor.construct($Gson$Types.getRawType(targetType));
}
public void visitArray(Object array, Type arrayType) {
@ -67,12 +67,12 @@ final class JsonArrayDeserializationVisitor<T> extends JsonDeserializationVisito
if (jsonChild == null || jsonChild.isJsonNull()) {
child = null;
} else if (jsonChild instanceof JsonObject) {
child = visitChildAsObject($Types.getArrayComponentType(arrayType), jsonChild);
child = visitChildAsObject($Gson$Types.getArrayComponentType(arrayType), jsonChild);
} else if (jsonChild instanceof JsonArray) {
child = visitChildAsArray($Types.getArrayComponentType(arrayType),
child = visitChildAsArray($Gson$Types.getArrayComponentType(arrayType),
jsonChild.getAsJsonArray());
} else if (jsonChild instanceof JsonPrimitive) {
child = visitChildAsObject($Types.getArrayComponentType(arrayType),
child = visitChildAsObject($Gson$Types.getArrayComponentType(arrayType),
jsonChild.getAsJsonPrimitive());
} else {
throw new IllegalStateException();

View File

@ -16,7 +16,7 @@
package com.google.gson;
import com.google.gson.internal.$Preconditions;
import com.google.gson.internal.$Gson$Preconditions;
import java.lang.reflect.Type;
@ -50,7 +50,7 @@ abstract class JsonDeserializationVisitor<T> implements ObjectNavigator.Visitor
this.fieldNamingPolicy = fieldNamingPolicy;
this.objectConstructor = objectConstructor;
this.deserializers = deserializers;
this.json = $Preconditions.checkNotNull(json);
this.json = $Gson$Preconditions.checkNotNull(json);
this.context = context;
this.constructed = false;
}

View File

@ -16,7 +16,7 @@
package com.google.gson;
import com.google.gson.internal.$Preconditions;
import com.google.gson.internal.$Gson$Preconditions;
import java.lang.reflect.Type;
@ -42,7 +42,7 @@ class JsonDeserializerExceptionWrapper<T> implements JsonDeserializer<T> {
* @throws IllegalArgumentException if {@code delegate} is {@code null}.
*/
JsonDeserializerExceptionWrapper(JsonDeserializer<T> delegate) {
this.delegate = $Preconditions.checkNotNull(delegate);
this.delegate = $Gson$Preconditions.checkNotNull(delegate);
}
public T deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)

View File

@ -16,7 +16,7 @@
package com.google.gson;
import com.google.gson.internal.$Preconditions;
import com.google.gson.internal.$Gson$Preconditions;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -46,8 +46,8 @@ class JsonFieldNameValidator {
* @throws IllegalArgumentException if the field name is an invalid JSON field name
*/
public String validate(String fieldName) {
$Preconditions.checkNotNull(fieldName);
$Preconditions.checkArgument(!"".equals(fieldName.trim()));
$Gson$Preconditions.checkNotNull(fieldName);
$Gson$Preconditions.checkArgument(!"".equals(fieldName.trim()));
Matcher matcher = JSON_FIELD_NAME_PATTERN.matcher(fieldName);
if (!matcher.matches()) {

View File

@ -16,7 +16,7 @@
package com.google.gson;
import com.google.gson.internal.$Preconditions;
import com.google.gson.internal.$Gson$Preconditions;
import java.io.IOException;
import java.util.LinkedHashMap;
@ -57,7 +57,7 @@ public final class JsonObject extends JsonElement {
if (value == null) {
value = JsonNull.createJsonNull();
}
members.put($Preconditions.checkNotNull(property), value);
members.put($Gson$Preconditions.checkNotNull(property), value);
}
/**

View File

@ -16,7 +16,7 @@
package com.google.gson;
import com.google.gson.internal.$Preconditions;
import com.google.gson.internal.$Gson$Preconditions;
import java.io.IOException;
import java.math.BigDecimal;
@ -94,7 +94,7 @@ public final class JsonPrimitive extends JsonElement {
char c = ((Character) primitive).charValue();
this.value = String.valueOf(c);
} else {
$Preconditions.checkArgument(primitive instanceof Number
$Gson$Preconditions.checkArgument(primitive instanceof Number
|| isPrimitiveOrString(primitive));
this.value = primitive;
}

View File

@ -16,8 +16,8 @@
package com.google.gson;
import com.google.gson.internal.$Types;
import com.google.gson.internal.$Preconditions;
import com.google.gson.internal.$Gson$Types;
import com.google.gson.internal.$Gson$Preconditions;
import java.lang.reflect.Array;
import java.lang.reflect.Type;
@ -76,7 +76,7 @@ final class JsonSerializationVisitor implements ObjectNavigator.Visitor {
public void visitArray(Object array, Type arrayType) {
assignToRoot(new JsonArray());
int length = Array.getLength(array);
Type componentType = $Types.getArrayComponentType(arrayType);
Type componentType = $Gson$Types.getArrayComponentType(arrayType);
for (int i = 0; i < length; ++i) {
Object child = Array.get(array, i);
// we should not get more specific component type yet since it is possible
@ -192,7 +192,7 @@ final class JsonSerializationVisitor implements ObjectNavigator.Visitor {
public boolean visitFieldUsingCustomHandler(
FieldAttributes f, Type declaredTypeOfField, Object parent) {
try {
$Preconditions.checkState(root.isJsonObject());
$Gson$Preconditions.checkState(root.isJsonObject());
Object obj = f.get(parent);
if (obj == null) {
if (serializeNulls) {
@ -215,7 +215,7 @@ final class JsonSerializationVisitor implements ObjectNavigator.Visitor {
}
private void assignToRoot(JsonElement newRoot) {
root = $Preconditions.checkNotNull(newRoot);
root = $Gson$Preconditions.checkNotNull(newRoot);
}
private boolean isFieldNull(FieldAttributes f, Object obj) {

View File

@ -16,7 +16,7 @@
package com.google.gson;
import com.google.gson.internal.$Types;
import com.google.gson.internal.$Gson$Types;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
@ -37,8 +37,8 @@ final class MapTypeAdapter extends BaseMapTypeAdapter {
JsonObject map = new JsonObject();
Type childGenericType = null;
if (typeOfSrc instanceof ParameterizedType) {
Class<?> rawTypeOfSrc = $Types.getRawType(typeOfSrc);
childGenericType = $Types.getMapKeyAndValueTypes(typeOfSrc, rawTypeOfSrc)[1];
Class<?> rawTypeOfSrc = $Gson$Types.getRawType(typeOfSrc);
childGenericType = $Gson$Types.getMapKeyAndValueTypes(typeOfSrc, rawTypeOfSrc)[1];
}
for (Map.Entry entry : (Set<Map.Entry>) src.entrySet()) {
@ -62,7 +62,7 @@ final class MapTypeAdapter extends BaseMapTypeAdapter {
// Use ObjectConstructor to create instance instead of hard-coding a specific type.
// This handles cases where users are using their own subclass of Map.
Map<Object, Object> map = constructMapType(typeOfT, context);
Type[] keyAndValueTypes = $Types.getMapKeyAndValueTypes(typeOfT, $Types.getRawType(typeOfT));
Type[] keyAndValueTypes = $Gson$Types.getMapKeyAndValueTypes(typeOfT, $Gson$Types.getRawType(typeOfT));
for (Map.Entry<String, JsonElement> entry : json.getAsJsonObject().entrySet()) {
Object key = context.deserialize(new JsonPrimitive(entry.getKey()), keyAndValueTypes[0]);
Object value = context.deserialize(entry.getValue(), keyAndValueTypes[1]);

View File

@ -16,7 +16,7 @@
package com.google.gson;
import com.google.gson.internal.$Types;
import com.google.gson.internal.$Gson$Types;
import java.lang.reflect.Array;
import java.lang.reflect.Type;
@ -53,13 +53,13 @@ final class MappedObjectConstructor implements ObjectConstructor {
}
public Object constructArray(Type type, int length) {
return Array.newInstance($Types.getRawType(type), length);
return Array.newInstance($Gson$Types.getRawType(type), length);
}
@SuppressWarnings({"unchecked", "cast"})
private <T> T constructWithAllocators(Type typeOfT) {
try {
Class<T> clazz = (Class<T>) $Types.getRawType(typeOfT);
Class<T> clazz = (Class<T>) $Gson$Types.getRawType(typeOfT);
T obj = defaultConstructorAllocator.newInstance(clazz);
return (obj == null)
? unsafeAllocator.newInstance(clazz)

View File

@ -16,7 +16,7 @@
package com.google.gson;
import com.google.gson.internal.$Preconditions;
import com.google.gson.internal.$Gson$Preconditions;
import java.util.Stack;
@ -37,7 +37,7 @@ final class MemoryRefStack {
* @return the object that was added
*/
public ObjectTypePair push(ObjectTypePair obj) {
$Preconditions.checkNotNull(obj);
$Gson$Preconditions.checkNotNull(obj);
return stack.push(obj);
}

View File

@ -16,7 +16,7 @@
package com.google.gson;
import com.google.gson.internal.$Preconditions;
import com.google.gson.internal.$Gson$Preconditions;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
@ -65,7 +65,7 @@ final class ModifyFirstLetterNamingPolicy extends RecursiveFieldNamingPolicy {
* @throws IllegalArgumentException if {@code modifier} is null
*/
ModifyFirstLetterNamingPolicy(LetterModifier modifier) {
this.letterModifier = $Preconditions.checkNotNull(modifier);
this.letterModifier = $Gson$Preconditions.checkNotNull(modifier);
}
@Override

View File

@ -16,7 +16,7 @@
package com.google.gson;
import com.google.gson.internal.$Types;
import com.google.gson.internal.$Gson$Types;
import java.lang.reflect.Type;
@ -95,7 +95,7 @@ final class ObjectNavigator {
* @param objTypePair The object,type (fully genericized) being navigated
*/
public void accept(ObjectTypePair objTypePair, Visitor visitor) {
if (exclusionStrategy.shouldSkipClass($Types.getRawType(objTypePair.type))) {
if (exclusionStrategy.shouldSkipClass($Gson$Types.getRawType(objTypePair.type))) {
return;
}
boolean visitedWithCustomHandler = visitor.visitUsingCustomHandler(objTypePair);
@ -108,7 +108,7 @@ final class ObjectNavigator {
objTypePair.setObject(objectToVisit);
visitor.start(objTypePair);
try {
if ($Types.isArray(objTypePair.type)) {
if ($Gson$Types.isArray(objTypePair.type)) {
visitor.visitArray(objectToVisit, objTypePair.type);
} else if (objTypePair.type == Object.class && isPrimitiveOrString(objectToVisit)) {
// TODO(Joel): this is only used for deserialization of "primitives"

View File

@ -16,7 +16,7 @@
package com.google.gson;
import com.google.gson.internal.$Types;
import com.google.gson.internal.$Gson$Types;
import java.lang.reflect.Type;
import java.util.ArrayList;
@ -138,7 +138,7 @@ final class ParameterizedTypeHandlerMap<T> {
public synchronized T getHandlerFor(Type type) {
T handler = map.get(type);
if (handler == null) {
Class<?> rawClass = $Types.getRawType(type);
Class<?> rawClass = $Gson$Types.getRawType(type);
if (rawClass != type) {
handler = getHandlerFor(rawClass);
}
@ -210,6 +210,6 @@ final class ParameterizedTypeHandlerMap<T> {
}
private String typeToString(Type type) {
return $Types.getRawType(type).getSimpleName();
return $Gson$Types.getRawType(type).getSimpleName();
}
}

View File

@ -22,7 +22,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import com.google.gson.internal.$Preconditions;
import com.google.gson.internal.$Gson$Preconditions;
/**
* Contains static utility methods pertaining to primitive types and their
@ -80,7 +80,7 @@ final class Primitives {
*/
public static boolean isWrapperType(Class<?> type) {
return WRAPPER_TO_PRIMITIVE_TYPE.containsKey(
$Preconditions.checkNotNull(type));
$Gson$Preconditions.checkNotNull(type));
}
/**
@ -96,7 +96,7 @@ final class Primitives {
// cast is safe: long.class and Long.class are both of type Class<Long>
@SuppressWarnings("unchecked")
Class<T> wrapped = (Class<T>) PRIMITIVE_TO_WRAPPER_TYPE.get(
$Preconditions.checkNotNull(type));
$Gson$Preconditions.checkNotNull(type));
return (wrapped == null) ? type : wrapped;
}
@ -113,7 +113,7 @@ final class Primitives {
// cast is safe: long.class and Long.class are both of type Class<Long>
@SuppressWarnings("unchecked")
Class<T> unwrapped = (Class<T>) WRAPPER_TO_PRIMITIVE_TYPE.get(
$Preconditions.checkNotNull(type));
$Gson$Preconditions.checkNotNull(type));
return (unwrapped == null) ? type : unwrapped;
}
}

View File

@ -22,8 +22,8 @@ import java.util.ArrayList;
import java.util.List;
import com.google.gson.ObjectNavigator.Visitor;
import com.google.gson.internal.$Preconditions;
import com.google.gson.internal.$Types;
import com.google.gson.internal.$Gson$Preconditions;
import com.google.gson.internal.$Gson$Types;
/**
* Visits each of the fields of the specified class using reflection
@ -44,7 +44,7 @@ final class ReflectingFieldNavigator {
* object.
*/
ReflectingFieldNavigator(ExclusionStrategy exclusionStrategy) {
this.exclusionStrategy = $Preconditions.checkNotNull(exclusionStrategy);
this.exclusionStrategy = $Gson$Preconditions.checkNotNull(exclusionStrategy);
}
/**
@ -63,7 +63,7 @@ final class ReflectingFieldNavigator {
boolean visitedWithCustomHandler =
visitor.visitFieldUsingCustomHandler(fieldAttributes, resolvedTypeOfField, obj);
if (!visitedWithCustomHandler) {
if ($Types.isArray(resolvedTypeOfField)) {
if ($Gson$Types.isArray(resolvedTypeOfField)) {
visitor.visitArrayField(fieldAttributes, resolvedTypeOfField, obj);
} else {
visitor.visitObjectField(fieldAttributes, resolvedTypeOfField, obj);
@ -94,7 +94,7 @@ final class ReflectingFieldNavigator {
*/
private List<Class<?>> getInheritanceHierarchy(Type type) {
List<Class<?>> classes = new ArrayList<Class<?>>();
Class<?> topLevelClass = $Types.getRawType(type);
Class<?> topLevelClass = $Gson$Types.getRawType(type);
for (Class<?> curr = topLevelClass; curr != null && !curr.equals(Object.class); curr =
curr.getSuperclass()) {
if (!curr.isSynthetic()) {

View File

@ -18,7 +18,7 @@ package com.google.gson;
import com.google.gson.annotations.Since;
import com.google.gson.annotations.Until;
import com.google.gson.internal.$Preconditions;
import com.google.gson.internal.$Gson$Preconditions;
/**
* This strategy will exclude any files and/or class that are passed the
@ -30,7 +30,7 @@ final class VersionExclusionStrategy implements ExclusionStrategy {
private final double version;
VersionExclusionStrategy(double version) {
$Preconditions.checkArgument(version >= 0.0D);
$Gson$Preconditions.checkArgument(version >= 0.0D);
this.version = version;
}

View File

@ -29,7 +29,7 @@ package com.google.gson.internal;
* @author Inderjeet Singh
* @author Joel Leitch
*/
public final class $Preconditions {
public final class $Gson$Preconditions {
public static <T> T checkNotNull(T obj) {
if (obj == null) {
throw new NullPointerException();

View File

@ -16,8 +16,8 @@
package com.google.gson.internal;
import static com.google.gson.internal.$Preconditions.checkArgument;
import static com.google.gson.internal.$Preconditions.checkNotNull;
import static com.google.gson.internal.$Gson$Preconditions.checkArgument;
import static com.google.gson.internal.$Gson$Preconditions.checkNotNull;
import java.io.Serializable;
import java.lang.reflect.Array;
import java.lang.reflect.GenericArrayType;
@ -38,10 +38,10 @@ import java.util.Properties;
* @author Bob Lee
* @author Jesse Wilson
*/
public final class $Types {
public final class $Gson$Types {
static final Type[] EMPTY_TYPE_ARRAY = new Type[] {};
private $Types() {}
private $Gson$Types() {}
/**
* Returns a new parameterized type, applying {@code typeArguments} to
@ -269,7 +269,7 @@ public final class $Types {
static Type getSupertype(Type context, Class<?> contextRawType, Class<?> supertype) {
checkArgument(supertype.isAssignableFrom(contextRawType));
return resolve(context, contextRawType,
$Types.getGenericSupertype(context, contextRawType, supertype));
$Gson$Types.getGenericSupertype(context, contextRawType, supertype));
}
/**
@ -435,7 +435,7 @@ public final class $Types {
checkArgument(!(type instanceof Class<?>) || !((Class<?>) type).isPrimitive());
}
private static class ParameterizedTypeImpl implements ParameterizedType, Serializable {
private static final class ParameterizedTypeImpl implements ParameterizedType, Serializable {
private final Type ownerType;
private final Type rawType;
private final Type[] typeArguments;
@ -473,7 +473,7 @@ public final class $Types {
@Override public boolean equals(Object other) {
return other instanceof ParameterizedType
&& $Types.equals(this, (ParameterizedType) other);
&& $Gson$Types.equals(this, (ParameterizedType) other);
}
@Override public int hashCode() {
@ -500,7 +500,7 @@ public final class $Types {
private static final long serialVersionUID = 0;
}
private static class GenericArrayTypeImpl implements GenericArrayType, Serializable {
private static final class GenericArrayTypeImpl implements GenericArrayType, Serializable {
private final Type componentType;
public GenericArrayTypeImpl(Type componentType) {
@ -513,7 +513,7 @@ public final class $Types {
@Override public boolean equals(Object o) {
return o instanceof GenericArrayType
&& $Types.equals(this, (GenericArrayType) o);
&& $Gson$Types.equals(this, (GenericArrayType) o);
}
@Override public int hashCode() {
@ -532,7 +532,7 @@ public final class $Types {
* lower bounds. We only support what the Java 6 language needs - at most one
* bound. If a lower bound is set, the upper bound must be Object.class.
*/
private static class WildcardTypeImpl implements WildcardType, Serializable {
private static final class WildcardTypeImpl implements WildcardType, Serializable {
private final Type upperBound;
private final Type lowerBound;
@ -565,7 +565,7 @@ public final class $Types {
@Override public boolean equals(Object other) {
return other instanceof WildcardType
&& $Types.equals(this, (WildcardType) other);
&& $Gson$Types.equals(this, (WildcardType) other);
}
@Override public int hashCode() {

View File

@ -16,8 +16,8 @@
package com.google.gson.reflect;
import com.google.gson.internal.$Types;
import com.google.gson.internal.$Preconditions;
import com.google.gson.internal.$Gson$Types;
import com.google.gson.internal.$Gson$Preconditions;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
@ -61,7 +61,7 @@ public class TypeToken<T> {
@SuppressWarnings("unchecked")
protected TypeToken() {
this.type = getSuperclassTypeParameter(getClass());
this.rawType = (Class<? super T>) $Types.getRawType(type);
this.rawType = (Class<? super T>) $Gson$Types.getRawType(type);
this.hashCode = type.hashCode();
}
@ -70,13 +70,13 @@ public class TypeToken<T> {
*/
@SuppressWarnings("unchecked")
TypeToken(Type type) {
this.type = $Types.canonicalize($Preconditions.checkNotNull(type));
this.rawType = (Class<? super T>) $Types.getRawType(this.type);
this.type = $Gson$Types.canonicalize($Gson$Preconditions.checkNotNull(type));
this.rawType = (Class<? super T>) $Gson$Types.getRawType(this.type);
this.hashCode = this.type.hashCode();
}
/**
* Returns the type from super class's type parameter in {@link $Types#canonicalize
* Returns the type from super class's type parameter in {@link $Gson$Types#canonicalize
* canonical form}.
*/
@SuppressWarnings("unchecked")
@ -86,7 +86,7 @@ public class TypeToken<T> {
throw new RuntimeException("Missing type parameter.");
}
ParameterizedType parameterized = (ParameterizedType) superclass;
return $Types.canonicalize(parameterized.getActualTypeArguments()[0]);
return $Gson$Types.canonicalize(parameterized.getActualTypeArguments()[0]);
}
/**
@ -131,12 +131,12 @@ public class TypeToken<T> {
}
if (type instanceof Class<?>) {
return rawType.isAssignableFrom($Types.getRawType(from));
return rawType.isAssignableFrom($Gson$Types.getRawType(from));
} else if (type instanceof ParameterizedType) {
return isAssignableFrom(from, (ParameterizedType) type,
new HashMap<String, Type>());
} else if (type instanceof GenericArrayType) {
return rawType.isAssignableFrom($Types.getRawType(from))
return rawType.isAssignableFrom($Gson$Types.getRawType(from))
&& isAssignableFrom(from, (GenericArrayType) type);
} else {
throw buildUnexpectedTypeError(
@ -196,7 +196,7 @@ public class TypeToken<T> {
}
// First figure out the class and any type information.
Class<?> clazz = $Types.getRawType(from);
Class<?> clazz = $Gson$Types.getRawType(from);
ParameterizedType ptype = null;
if (from instanceof ParameterizedType) {
ptype = (ParameterizedType) from;
@ -285,11 +285,11 @@ public class TypeToken<T> {
@Override public final boolean equals(Object o) {
return o instanceof TypeToken<?>
&& $Types.equals(type, ((TypeToken<?>) o).type);
&& $Gson$Types.equals(type, ((TypeToken<?>) o).type);
}
@Override public final String toString() {
return $Types.typeToString(type);
return $Gson$Types.typeToString(type);
}
/**

View File

@ -16,7 +16,7 @@
package com.google.gson;
import com.google.gson.internal.$Types;
import com.google.gson.internal.$Gson$Types;
import com.google.gson.reflect.TypeToken;
import junit.framework.TestCase;
@ -26,7 +26,7 @@ import java.lang.reflect.Type;
import java.util.List;
/**
* Unit tests for the {@code GenericArrayType}s created by the {@link $Types} class.
* Unit tests for the {@code GenericArrayType}s created by the {@link $Gson$Types} class.
*
* @author Inderjeet Singh
* @author Joel Leitch
@ -37,7 +37,7 @@ public class GenericArrayTypeTest extends TestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
ourType = $Types.arrayOf($Types.newParameterizedTypeWithOwner(null, List.class, String.class));
ourType = $Gson$Types.arrayOf($Gson$Types.newParameterizedTypeWithOwner(null, List.class, String.class));
}
public void testOurTypeFunctionality() throws Exception {

View File

@ -16,7 +16,7 @@
package com.google.gson;
import com.google.gson.internal.$Types;
import com.google.gson.internal.$Gson$Types;
import com.google.gson.reflect.TypeToken;
import junit.framework.TestCase;
@ -26,7 +26,7 @@ import java.lang.reflect.Type;
import java.util.List;
/**
* Unit tests for {@code ParamterizedType}s created by the {@link $Types} class.
* Unit tests for {@code ParamterizedType}s created by the {@link $Gson$Types} class.
*
* @author Inderjeet Singh
* @author Joel Leitch
@ -37,7 +37,7 @@ public class ParameterizedTypeTest extends TestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
ourType = $Types.newParameterizedTypeWithOwner(null, List.class, String.class);
ourType = $Gson$Types.newParameterizedTypeWithOwner(null, List.class, String.class);
}
public void testOurTypeFunctionality() throws Exception {

View File

@ -16,7 +16,7 @@
package com.google.gson;
import com.google.gson.internal.$Types;
import com.google.gson.internal.$Gson$Types;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@ -152,7 +152,7 @@ public class ParamterizedTypeFixtures {
public MyParameterizedType<T> deserialize(JsonElement json, Type typeOfT,
JsonDeserializationContext context) throws JsonParseException {
Type genericClass = ((ParameterizedType) typeOfT).getActualTypeArguments()[0];
Class<?> rawType = $Types.getRawType(genericClass);
Class<?> rawType = $Gson$Types.getRawType(genericClass);
String className = rawType.getSimpleName();
T value = (T) json.getAsJsonObject().get(className).getAsObject();
if (Primitives.isPrimitive(genericClass)) {