From c8bd121db2b382cc0e15d317b19178e6db373d9b Mon Sep 17 00:00:00 2001 From: Inderjeet Singh Date: Wed, 6 Apr 2011 00:26:57 +0000 Subject: [PATCH] Renamed $Preconditions to $Gson$Preconditions and $Types to $Gson$Types. Marked the two private classes in $Types as final. --- .../gson/CamelCaseSeparatorNamingPolicy.java | 6 ++--- .../com/google/gson/DefaultTypeAdapters.java | 10 ++++---- .../gson/DelegatingJsonElementVisitor.java | 4 ++-- .../gson/DisjunctionExclusionStrategy.java | 4 ++-- .../java/com/google/gson/FieldAttributes.java | 12 +++++----- .../gson/FieldNamingStrategy2Adapter.java | 4 ++-- .../java/com/google/gson/GsonBuilder.java | 6 ++--- .../gson/JsonArrayDeserializationVisitor.java | 14 +++++------ .../gson/JsonDeserializationVisitor.java | 4 ++-- .../JsonDeserializerExceptionWrapper.java | 4 ++-- .../google/gson/JsonFieldNameValidator.java | 6 ++--- .../main/java/com/google/gson/JsonObject.java | 4 ++-- .../java/com/google/gson/JsonPrimitive.java | 4 ++-- .../google/gson/JsonSerializationVisitor.java | 10 ++++---- .../java/com/google/gson/MapTypeAdapter.java | 8 +++---- .../google/gson/MappedObjectConstructor.java | 6 ++--- .../java/com/google/gson/MemoryRefStack.java | 4 ++-- .../gson/ModifyFirstLetterNamingPolicy.java | 4 ++-- .../java/com/google/gson/ObjectNavigator.java | 6 ++--- .../gson/ParameterizedTypeHandlerMap.java | 6 ++--- .../main/java/com/google/gson/Primitives.java | 8 +++---- .../google/gson/ReflectingFieldNavigator.java | 10 ++++---- .../google/gson/VersionExclusionStrategy.java | 4 ++-- ...nditions.java => $Gson$Preconditions.java} | 2 +- .../{$Types.java => $Gson$Types.java} | 22 ++++++++--------- .../com/google/gson/reflect/TypeToken.java | 24 +++++++++---------- .../com/google/gson/GenericArrayTypeTest.java | 6 ++--- .../google/gson/ParameterizedTypeTest.java | 6 ++--- .../google/gson/ParamterizedTypeFixtures.java | 4 ++-- 29 files changed, 106 insertions(+), 106 deletions(-) rename gson/src/main/java/com/google/gson/internal/{$Preconditions.java => $Gson$Preconditions.java} (93%) rename gson/src/main/java/com/google/gson/internal/{$Types.java => $Gson$Types.java} (96%) diff --git a/gson/src/main/java/com/google/gson/CamelCaseSeparatorNamingPolicy.java b/gson/src/main/java/com/google/gson/CamelCaseSeparatorNamingPolicy.java index fd114a91..947c4b2a 100644 --- a/gson/src/main/java/com/google/gson/CamelCaseSeparatorNamingPolicy.java +++ b/gson/src/main/java/com/google/gson/CamelCaseSeparatorNamingPolicy.java @@ -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; } diff --git a/gson/src/main/java/com/google/gson/DefaultTypeAdapters.java b/gson/src/main/java/com/google/gson/DefaultTypeAdapters.java index 121aa994..54282353 100644 --- a/gson/src/main/java/com/google/gson/DefaultTypeAdapters.java +++ b/gson/src/main/java/com/google/gson/DefaultTypeAdapters.java @@ -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) diff --git a/gson/src/main/java/com/google/gson/DelegatingJsonElementVisitor.java b/gson/src/main/java/com/google/gson/DelegatingJsonElementVisitor.java index 34b21ec0..a16bac05 100644 --- a/gson/src/main/java/com/google/gson/DelegatingJsonElementVisitor.java +++ b/gson/src/main/java/com/google/gson/DelegatingJsonElementVisitor.java @@ -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 { diff --git a/gson/src/main/java/com/google/gson/DisjunctionExclusionStrategy.java b/gson/src/main/java/com/google/gson/DisjunctionExclusionStrategy.java index d4edb9d8..cb017076 100644 --- a/gson/src/main/java/com/google/gson/DisjunctionExclusionStrategy.java +++ b/gson/src/main/java/com/google/gson/DisjunctionExclusionStrategy.java @@ -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 strategies; DisjunctionExclusionStrategy(Collection strategies) { - this.strategies = $Preconditions.checkNotNull(strategies); + this.strategies = $Gson$Preconditions.checkNotNull(strategies); } public boolean shouldSkipField(FieldAttributes f) { diff --git a/gson/src/main/java/com/google/gson/FieldAttributes.java b/gson/src/main/java/com/google/gson/FieldAttributes.java index f847b20e..18ceb90a 100644 --- a/gson/src/main/java/com/google/gson/FieldAttributes.java +++ b/gson/src/main/java/com/google/gson/FieldAttributes.java @@ -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 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()); } } diff --git a/gson/src/main/java/com/google/gson/FieldNamingStrategy2Adapter.java b/gson/src/main/java/com/google/gson/FieldNamingStrategy2Adapter.java index 15f939c4..88b81c5f 100644 --- a/gson/src/main/java/com/google/gson/FieldNamingStrategy2Adapter.java +++ b/gson/src/main/java/com/google/gson/FieldNamingStrategy2Adapter.java @@ -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) { diff --git a/gson/src/main/java/com/google/gson/GsonBuilder.java b/gson/src/main/java/com/google/gson/GsonBuilder.java index 83092272..0d1686f6 100644 --- a/gson/src/main/java/com/google/gson/GsonBuilder.java +++ b/gson/src/main/java/com/google/gson/GsonBuilder.java @@ -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); diff --git a/gson/src/main/java/com/google/gson/JsonArrayDeserializationVisitor.java b/gson/src/main/java/com/google/gson/JsonArrayDeserializationVisitor.java index 9eb08fd6..c7806acf 100644 --- a/gson/src/main/java/com/google/gson/JsonArrayDeserializationVisitor.java +++ b/gson/src/main/java/com/google/gson/JsonArrayDeserializationVisitor.java @@ -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 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 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(); diff --git a/gson/src/main/java/com/google/gson/JsonDeserializationVisitor.java b/gson/src/main/java/com/google/gson/JsonDeserializationVisitor.java index fb497c1b..5403884a 100644 --- a/gson/src/main/java/com/google/gson/JsonDeserializationVisitor.java +++ b/gson/src/main/java/com/google/gson/JsonDeserializationVisitor.java @@ -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 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; } diff --git a/gson/src/main/java/com/google/gson/JsonDeserializerExceptionWrapper.java b/gson/src/main/java/com/google/gson/JsonDeserializerExceptionWrapper.java index 8ed07c7f..9a699ca1 100644 --- a/gson/src/main/java/com/google/gson/JsonDeserializerExceptionWrapper.java +++ b/gson/src/main/java/com/google/gson/JsonDeserializerExceptionWrapper.java @@ -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 implements JsonDeserializer { * @throws IllegalArgumentException if {@code delegate} is {@code null}. */ JsonDeserializerExceptionWrapper(JsonDeserializer delegate) { - this.delegate = $Preconditions.checkNotNull(delegate); + this.delegate = $Gson$Preconditions.checkNotNull(delegate); } public T deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) diff --git a/gson/src/main/java/com/google/gson/JsonFieldNameValidator.java b/gson/src/main/java/com/google/gson/JsonFieldNameValidator.java index c18042a3..07027b92 100644 --- a/gson/src/main/java/com/google/gson/JsonFieldNameValidator.java +++ b/gson/src/main/java/com/google/gson/JsonFieldNameValidator.java @@ -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()) { diff --git a/gson/src/main/java/com/google/gson/JsonObject.java b/gson/src/main/java/com/google/gson/JsonObject.java index 98c43ce6..91e5f143 100644 --- a/gson/src/main/java/com/google/gson/JsonObject.java +++ b/gson/src/main/java/com/google/gson/JsonObject.java @@ -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); } /** diff --git a/gson/src/main/java/com/google/gson/JsonPrimitive.java b/gson/src/main/java/com/google/gson/JsonPrimitive.java index c39a7bfc..9ba5beb8 100644 --- a/gson/src/main/java/com/google/gson/JsonPrimitive.java +++ b/gson/src/main/java/com/google/gson/JsonPrimitive.java @@ -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; } diff --git a/gson/src/main/java/com/google/gson/JsonSerializationVisitor.java b/gson/src/main/java/com/google/gson/JsonSerializationVisitor.java index 875d1f75..a3725d61 100644 --- a/gson/src/main/java/com/google/gson/JsonSerializationVisitor.java +++ b/gson/src/main/java/com/google/gson/JsonSerializationVisitor.java @@ -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) { diff --git a/gson/src/main/java/com/google/gson/MapTypeAdapter.java b/gson/src/main/java/com/google/gson/MapTypeAdapter.java index 5851b5a4..23e91a09 100644 --- a/gson/src/main/java/com/google/gson/MapTypeAdapter.java +++ b/gson/src/main/java/com/google/gson/MapTypeAdapter.java @@ -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) 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 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 entry : json.getAsJsonObject().entrySet()) { Object key = context.deserialize(new JsonPrimitive(entry.getKey()), keyAndValueTypes[0]); Object value = context.deserialize(entry.getValue(), keyAndValueTypes[1]); diff --git a/gson/src/main/java/com/google/gson/MappedObjectConstructor.java b/gson/src/main/java/com/google/gson/MappedObjectConstructor.java index d9afec19..86fdfdd9 100644 --- a/gson/src/main/java/com/google/gson/MappedObjectConstructor.java +++ b/gson/src/main/java/com/google/gson/MappedObjectConstructor.java @@ -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 constructWithAllocators(Type typeOfT) { try { - Class clazz = (Class) $Types.getRawType(typeOfT); + Class clazz = (Class) $Gson$Types.getRawType(typeOfT); T obj = defaultConstructorAllocator.newInstance(clazz); return (obj == null) ? unsafeAllocator.newInstance(clazz) diff --git a/gson/src/main/java/com/google/gson/MemoryRefStack.java b/gson/src/main/java/com/google/gson/MemoryRefStack.java index d2c7a604..3fbd8463 100644 --- a/gson/src/main/java/com/google/gson/MemoryRefStack.java +++ b/gson/src/main/java/com/google/gson/MemoryRefStack.java @@ -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); } diff --git a/gson/src/main/java/com/google/gson/ModifyFirstLetterNamingPolicy.java b/gson/src/main/java/com/google/gson/ModifyFirstLetterNamingPolicy.java index a8a152a5..4de407fd 100644 --- a/gson/src/main/java/com/google/gson/ModifyFirstLetterNamingPolicy.java +++ b/gson/src/main/java/com/google/gson/ModifyFirstLetterNamingPolicy.java @@ -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 diff --git a/gson/src/main/java/com/google/gson/ObjectNavigator.java b/gson/src/main/java/com/google/gson/ObjectNavigator.java index a1db6029..84141f06 100644 --- a/gson/src/main/java/com/google/gson/ObjectNavigator.java +++ b/gson/src/main/java/com/google/gson/ObjectNavigator.java @@ -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" diff --git a/gson/src/main/java/com/google/gson/ParameterizedTypeHandlerMap.java b/gson/src/main/java/com/google/gson/ParameterizedTypeHandlerMap.java index c44aa2ab..a4e7b411 100644 --- a/gson/src/main/java/com/google/gson/ParameterizedTypeHandlerMap.java +++ b/gson/src/main/java/com/google/gson/ParameterizedTypeHandlerMap.java @@ -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 { 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 { } private String typeToString(Type type) { - return $Types.getRawType(type).getSimpleName(); + return $Gson$Types.getRawType(type).getSimpleName(); } } diff --git a/gson/src/main/java/com/google/gson/Primitives.java b/gson/src/main/java/com/google/gson/Primitives.java index 6ec5f0d1..7d43f7de 100644 --- a/gson/src/main/java/com/google/gson/Primitives.java +++ b/gson/src/main/java/com/google/gson/Primitives.java @@ -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 @SuppressWarnings("unchecked") Class wrapped = (Class) 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 @SuppressWarnings("unchecked") Class unwrapped = (Class) WRAPPER_TO_PRIMITIVE_TYPE.get( - $Preconditions.checkNotNull(type)); + $Gson$Preconditions.checkNotNull(type)); return (unwrapped == null) ? type : unwrapped; } } diff --git a/gson/src/main/java/com/google/gson/ReflectingFieldNavigator.java b/gson/src/main/java/com/google/gson/ReflectingFieldNavigator.java index fee901d9..eee28e61 100644 --- a/gson/src/main/java/com/google/gson/ReflectingFieldNavigator.java +++ b/gson/src/main/java/com/google/gson/ReflectingFieldNavigator.java @@ -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> getInheritanceHierarchy(Type type) { List> classes = new ArrayList>(); - 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()) { diff --git a/gson/src/main/java/com/google/gson/VersionExclusionStrategy.java b/gson/src/main/java/com/google/gson/VersionExclusionStrategy.java index ecbf7f3b..5d5239f2 100644 --- a/gson/src/main/java/com/google/gson/VersionExclusionStrategy.java +++ b/gson/src/main/java/com/google/gson/VersionExclusionStrategy.java @@ -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; } diff --git a/gson/src/main/java/com/google/gson/internal/$Preconditions.java b/gson/src/main/java/com/google/gson/internal/$Gson$Preconditions.java similarity index 93% rename from gson/src/main/java/com/google/gson/internal/$Preconditions.java rename to gson/src/main/java/com/google/gson/internal/$Gson$Preconditions.java index 0487221a..276912da 100644 --- a/gson/src/main/java/com/google/gson/internal/$Preconditions.java +++ b/gson/src/main/java/com/google/gson/internal/$Gson$Preconditions.java @@ -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 checkNotNull(T obj) { if (obj == null) { throw new NullPointerException(); diff --git a/gson/src/main/java/com/google/gson/internal/$Types.java b/gson/src/main/java/com/google/gson/internal/$Gson$Types.java similarity index 96% rename from gson/src/main/java/com/google/gson/internal/$Types.java rename to gson/src/main/java/com/google/gson/internal/$Gson$Types.java index fd6999f5..f03dc77f 100644 --- a/gson/src/main/java/com/google/gson/internal/$Types.java +++ b/gson/src/main/java/com/google/gson/internal/$Gson$Types.java @@ -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() { diff --git a/gson/src/main/java/com/google/gson/reflect/TypeToken.java b/gson/src/main/java/com/google/gson/reflect/TypeToken.java index 1b2f5890..59595513 100644 --- a/gson/src/main/java/com/google/gson/reflect/TypeToken.java +++ b/gson/src/main/java/com/google/gson/reflect/TypeToken.java @@ -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 { @SuppressWarnings("unchecked") protected TypeToken() { this.type = getSuperclassTypeParameter(getClass()); - this.rawType = (Class) $Types.getRawType(type); + this.rawType = (Class) $Gson$Types.getRawType(type); this.hashCode = type.hashCode(); } @@ -70,13 +70,13 @@ public class TypeToken { */ @SuppressWarnings("unchecked") TypeToken(Type type) { - this.type = $Types.canonicalize($Preconditions.checkNotNull(type)); - this.rawType = (Class) $Types.getRawType(this.type); + this.type = $Gson$Types.canonicalize($Gson$Preconditions.checkNotNull(type)); + this.rawType = (Class) $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 { 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 { } 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()); } 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 { } // 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 { @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); } /** diff --git a/gson/src/test/java/com/google/gson/GenericArrayTypeTest.java b/gson/src/test/java/com/google/gson/GenericArrayTypeTest.java index 242421db..42acb8a2 100644 --- a/gson/src/test/java/com/google/gson/GenericArrayTypeTest.java +++ b/gson/src/test/java/com/google/gson/GenericArrayTypeTest.java @@ -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 { diff --git a/gson/src/test/java/com/google/gson/ParameterizedTypeTest.java b/gson/src/test/java/com/google/gson/ParameterizedTypeTest.java index b18eabff..8b56579e 100644 --- a/gson/src/test/java/com/google/gson/ParameterizedTypeTest.java +++ b/gson/src/test/java/com/google/gson/ParameterizedTypeTest.java @@ -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 { diff --git a/gson/src/test/java/com/google/gson/ParamterizedTypeFixtures.java b/gson/src/test/java/com/google/gson/ParamterizedTypeFixtures.java index a533df08..96062fae 100644 --- a/gson/src/test/java/com/google/gson/ParamterizedTypeFixtures.java +++ b/gson/src/test/java/com/google/gson/ParamterizedTypeFixtures.java @@ -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 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)) {