From 5bc80cd6937faae894c5b578b78ed071c7c8d61d Mon Sep 17 00:00:00 2001 From: Inderjeet Singh Date: Wed, 30 Mar 2011 13:59:06 +0000 Subject: [PATCH] Moved Cache, LruCache, Pair, Primitives and UnsafeAllocator to com.google.gson and made them package private. --- .../gson/{internal/$Cache.java => Cache.java} | 4 ++-- .../gson/DefaultConstructorAllocator.java | 6 ++---- .../java/com/google/gson/FieldAttributes.java | 9 +++------ gson/src/main/java/com/google/gson/Gson.java | 7 +++---- .../google/gson/JsonDeserializationVisitor.java | 5 ++--- .../gson/JsonObjectDeserializationVisitor.java | 6 ++---- .../google/gson/JsonSerializationVisitor.java | 3 +-- .../{internal/$LruCache.java => LruCache.java} | 8 ++++---- .../google/gson/MappedObjectConstructor.java | 3 +-- .../java/com/google/gson/ObjectNavigator.java | 3 +-- .../java/com/google/gson/ObjectTypePair.java | 7 +++---- .../gson/{internal/$Pair.java => Pair.java} | 10 +++++----- .../gson/ParameterizedTypeHandlerMap.java | 17 ++++++++--------- .../$Primitives.java => Primitives.java} | 8 +++++--- .../google/gson/ReflectingFieldNavigator.java | 9 ++++----- ...nsafeAllocator.java => UnsafeAllocator.java} | 14 +++++++------- .../test/java/com/google/gson/LruCacheTest.java | 10 ++++------ .../google/gson/ParamterizedTypeFixtures.java | 7 +++---- .../com/google/gson/PrimitiveTypeAdapter.java | 5 ++--- 19 files changed, 62 insertions(+), 79 deletions(-) rename gson/src/main/java/com/google/gson/{internal/$Cache.java => Cache.java} (95%) rename gson/src/main/java/com/google/gson/{internal/$LruCache.java => LruCache.java} (83%) rename gson/src/main/java/com/google/gson/{internal/$Pair.java => Pair.java} (87%) rename gson/src/main/java/com/google/gson/{internal/$Primitives.java => Primitives.java} (96%) rename gson/src/main/java/com/google/gson/{internal/$UnsafeAllocator.java => UnsafeAllocator.java} (92%) diff --git a/gson/src/main/java/com/google/gson/internal/$Cache.java b/gson/src/main/java/com/google/gson/Cache.java similarity index 95% rename from gson/src/main/java/com/google/gson/internal/$Cache.java rename to gson/src/main/java/com/google/gson/Cache.java index 4fce2de3..ed56cd3c 100644 --- a/gson/src/main/java/com/google/gson/internal/$Cache.java +++ b/gson/src/main/java/com/google/gson/Cache.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.gson.internal; +package com.google.gson; /** * Defines generic cache interface. @@ -22,7 +22,7 @@ package com.google.gson.internal; * @author Inderjeet Singh * @author Joel Leitch */ -public interface $Cache { +interface Cache { /** * Adds the new value object into the cache for the given key. If the key already diff --git a/gson/src/main/java/com/google/gson/DefaultConstructorAllocator.java b/gson/src/main/java/com/google/gson/DefaultConstructorAllocator.java index dacb4d19..d4163ba8 100644 --- a/gson/src/main/java/com/google/gson/DefaultConstructorAllocator.java +++ b/gson/src/main/java/com/google/gson/DefaultConstructorAllocator.java @@ -16,8 +16,6 @@ package com.google.gson; -import com.google.gson.internal.$Cache; -import com.google.gson.internal.$LruCache; import java.lang.reflect.Constructor; @@ -30,14 +28,14 @@ class DefaultConstructorAllocator { private static final Constructor NULL_CONSTRUCTOR = createNullConstructor(); // Package private for testing purposes. - final $Cache, Constructor> constructorCache; + final Cache, Constructor> constructorCache; public DefaultConstructorAllocator() { this(200); } public DefaultConstructorAllocator(int cacheSize) { - constructorCache = new $LruCache, Constructor>(cacheSize); + constructorCache = new LruCache, Constructor>(cacheSize); } private static final Constructor createNullConstructor() { diff --git a/gson/src/main/java/com/google/gson/FieldAttributes.java b/gson/src/main/java/com/google/gson/FieldAttributes.java index b5839c01..9b30ea18 100644 --- a/gson/src/main/java/com/google/gson/FieldAttributes.java +++ b/gson/src/main/java/com/google/gson/FieldAttributes.java @@ -16,9 +16,6 @@ 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; @@ -42,8 +39,8 @@ public final class FieldAttributes { private static final String MAX_CACHE_PROPERTY_NAME = "com.google.gson.annotation_cache_size_hint"; - private static final $Cache<$Pair, String>, Collection> ANNOTATION_CACHE = - new $LruCache<$Pair,String>, Collection>(getMaxCacheSize()); + private static final Cache, String>, Collection> ANNOTATION_CACHE = + new LruCache,String>, Collection>(getMaxCacheSize()); private final Class declaringClazz; private final Field field; @@ -157,7 +154,7 @@ public final class FieldAttributes { */ public Collection getAnnotations() { if (annotations == null) { - $Pair, String> key = new $Pair, String>(declaringClazz, name); + Pair, String> key = new Pair, String>(declaringClazz, name); annotations = ANNOTATION_CACHE.getElement(key); if (annotations == null) { annotations = Collections.unmodifiableCollection( diff --git a/gson/src/main/java/com/google/gson/Gson.java b/gson/src/main/java/com/google/gson/Gson.java index 8f6e56d5..20517670 100644 --- a/gson/src/main/java/com/google/gson/Gson.java +++ b/gson/src/main/java/com/google/gson/Gson.java @@ -16,7 +16,6 @@ package com.google.gson; -import com.google.gson.internal.$Primitives; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonToken; import com.google.gson.stream.JsonWriter; @@ -388,7 +387,7 @@ public final class Gson { */ public T fromJson(String json, Class classOfT) throws JsonSyntaxException { Object object = fromJson(json, (Type) classOfT); - return $Primitives.wrap(classOfT).cast(object); + return Primitives.wrap(classOfT).cast(object); } /** @@ -441,7 +440,7 @@ public final class Gson { JsonReader jsonReader = new JsonReader(json); Object object = fromJson(jsonReader, classOfT); assertFullConsumption(object, jsonReader); - return $Primitives.wrap(classOfT).cast(object); + return Primitives.wrap(classOfT).cast(object); } /** @@ -520,7 +519,7 @@ public final class Gson { */ public T fromJson(JsonElement json, Class classOfT) throws JsonSyntaxException { Object object = fromJson(json, (Type) classOfT); - return $Primitives.wrap(classOfT).cast(object); + return Primitives.wrap(classOfT).cast(object); } /** diff --git a/gson/src/main/java/com/google/gson/JsonDeserializationVisitor.java b/gson/src/main/java/com/google/gson/JsonDeserializationVisitor.java index 2cb5ef2c..fb497c1b 100644 --- a/gson/src/main/java/com/google/gson/JsonDeserializationVisitor.java +++ b/gson/src/main/java/com/google/gson/JsonDeserializationVisitor.java @@ -16,7 +16,6 @@ package com.google.gson; -import com.google.gson.internal.$Pair; import com.google.gson.internal.$Preconditions; import java.lang.reflect.Type; @@ -74,7 +73,7 @@ abstract class JsonDeserializationVisitor implements ObjectNavigator.Visitor @SuppressWarnings("unchecked") public final boolean visitUsingCustomHandler(ObjectTypePair objTypePair) { - $Pair, ObjectTypePair> pair = objTypePair.getMatchingHandler(deserializers); + Pair, ObjectTypePair> pair = objTypePair.getMatchingHandler(deserializers); if (pair == null) { return false; } @@ -85,7 +84,7 @@ abstract class JsonDeserializationVisitor implements ObjectNavigator.Visitor } protected Object invokeCustomDeserializer(JsonElement element, - $Pair, ObjectTypePair> pair) { + Pair, ObjectTypePair> pair) { if (element == null || element.isJsonNull()) { return null; } diff --git a/gson/src/main/java/com/google/gson/JsonObjectDeserializationVisitor.java b/gson/src/main/java/com/google/gson/JsonObjectDeserializationVisitor.java index 716c3890..f1bf51c8 100644 --- a/gson/src/main/java/com/google/gson/JsonObjectDeserializationVisitor.java +++ b/gson/src/main/java/com/google/gson/JsonObjectDeserializationVisitor.java @@ -16,8 +16,6 @@ package com.google.gson; -import com.google.gson.internal.$Pair; -import com.google.gson.internal.$Primitives; import java.lang.reflect.Type; @@ -102,7 +100,7 @@ final class JsonObjectDeserializationVisitor extends JsonDeserializationVisit throw new JsonParseException("Expecting object found: " + json); } JsonElement child = json.getAsJsonObject().get(fName); - boolean isPrimitive = $Primitives.isPrimitive(declaredTypeOfField); + boolean isPrimitive = Primitives.isPrimitive(declaredTypeOfField); if (child == null) { // Child will be null if the field wasn't present in Json return true; } else if (child.isJsonNull()) { @@ -112,7 +110,7 @@ final class JsonObjectDeserializationVisitor extends JsonDeserializationVisit return true; } ObjectTypePair objTypePair = new ObjectTypePair(null, declaredTypeOfField, false); - $Pair, ObjectTypePair> pair = objTypePair.getMatchingHandler(deserializers); + Pair, ObjectTypePair> pair = objTypePair.getMatchingHandler(deserializers); if (pair == null) { return false; } diff --git a/gson/src/main/java/com/google/gson/JsonSerializationVisitor.java b/gson/src/main/java/com/google/gson/JsonSerializationVisitor.java index 17996ead..875d1f75 100644 --- a/gson/src/main/java/com/google/gson/JsonSerializationVisitor.java +++ b/gson/src/main/java/com/google/gson/JsonSerializationVisitor.java @@ -16,7 +16,6 @@ package com.google.gson; -import com.google.gson.internal.$Pair; import com.google.gson.internal.$Types; import com.google.gson.internal.$Preconditions; @@ -174,7 +173,7 @@ final class JsonSerializationVisitor implements ObjectNavigator.Visitor { */ @SuppressWarnings("unchecked") private JsonElement findAndInvokeCustomSerializer(ObjectTypePair objTypePair) { - $Pair,ObjectTypePair> pair = objTypePair.getMatchingHandler(serializers); + Pair,ObjectTypePair> pair = objTypePair.getMatchingHandler(serializers); if (pair == null) { return null; } diff --git a/gson/src/main/java/com/google/gson/internal/$LruCache.java b/gson/src/main/java/com/google/gson/LruCache.java similarity index 83% rename from gson/src/main/java/com/google/gson/internal/$LruCache.java rename to gson/src/main/java/com/google/gson/LruCache.java index 7892bc72..f88c5d02 100644 --- a/gson/src/main/java/com/google/gson/internal/$LruCache.java +++ b/gson/src/main/java/com/google/gson/LruCache.java @@ -14,26 +14,26 @@ * limitations under the License. */ -package com.google.gson.internal; +package com.google.gson; import java.util.LinkedHashMap; import java.util.Map; /** - * An implementation of the {@link $Cache} interface that evict objects from the cache using an + * An implementation of the {@link Cache} interface that evict objects from the cache using an * LRU (least recently used) algorithm. Object start getting evicted from the cache once the * {@code maxCapacity} is reached. * * @author Inderjeet Singh * @author Joel Leitch */ -public final class $LruCache extends LinkedHashMap implements $Cache { +final class LruCache extends LinkedHashMap implements Cache { private static final long serialVersionUID = 1L; private final int maxCapacity; - public $LruCache(int maxCapacity) { + public LruCache(int maxCapacity) { super(maxCapacity, 0.7F, true); this.maxCapacity = maxCapacity; } diff --git a/gson/src/main/java/com/google/gson/MappedObjectConstructor.java b/gson/src/main/java/com/google/gson/MappedObjectConstructor.java index 1d3e2813..d9afec19 100644 --- a/gson/src/main/java/com/google/gson/MappedObjectConstructor.java +++ b/gson/src/main/java/com/google/gson/MappedObjectConstructor.java @@ -17,7 +17,6 @@ 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.Type; @@ -33,7 +32,7 @@ import java.lang.reflect.Type; * @author Joel Leitch */ final class MappedObjectConstructor implements ObjectConstructor { - private static final $UnsafeAllocator unsafeAllocator = $UnsafeAllocator.create(); + private static final UnsafeAllocator unsafeAllocator = UnsafeAllocator.create(); private static final DefaultConstructorAllocator defaultConstructorAllocator = new DefaultConstructorAllocator(500); diff --git a/gson/src/main/java/com/google/gson/ObjectNavigator.java b/gson/src/main/java/com/google/gson/ObjectNavigator.java index 21549cf0..a1db6029 100644 --- a/gson/src/main/java/com/google/gson/ObjectNavigator.java +++ b/gson/src/main/java/com/google/gson/ObjectNavigator.java @@ -17,7 +17,6 @@ package com.google.gson; import com.google.gson.internal.$Types; -import com.google.gson.internal.$Primitives; import java.lang.reflect.Type; @@ -129,6 +128,6 @@ final class ObjectNavigator { private static boolean isPrimitiveOrString(Object objectToVisit) { Class realClazz = objectToVisit.getClass(); return realClazz == Object.class || realClazz == String.class - || $Primitives.unwrap(realClazz).isPrimitive(); + || Primitives.unwrap(realClazz).isPrimitive(); } } diff --git a/gson/src/main/java/com/google/gson/ObjectTypePair.java b/gson/src/main/java/com/google/gson/ObjectTypePair.java index 36f50b60..319ab63d 100644 --- a/gson/src/main/java/com/google/gson/ObjectTypePair.java +++ b/gson/src/main/java/com/google/gson/ObjectTypePair.java @@ -15,7 +15,6 @@ */ package com.google.gson; -import com.google.gson.internal.$Pair; import java.lang.reflect.Type; @@ -52,7 +51,7 @@ final class ObjectTypePair { return String.format("preserveType: %b, type: %s, obj: %s", preserveType, type, obj); } - $Pair getMatchingHandler( + Pair getMatchingHandler( ParameterizedTypeHandlerMap handlers) { HANDLER handler = null; if (!preserveType && obj != null) { @@ -60,12 +59,12 @@ final class ObjectTypePair { ObjectTypePair moreSpecificType = toMoreSpecificType(); handler = handlers.getHandlerFor(moreSpecificType.type); if (handler != null) { - return new $Pair(handler, moreSpecificType); + return new Pair(handler, moreSpecificType); } } // Try the specified type handler = handlers.getHandlerFor(type); - return handler == null ? null : new $Pair(handler, this); + return handler == null ? null : new Pair(handler, this); } ObjectTypePair toMoreSpecificType() { diff --git a/gson/src/main/java/com/google/gson/internal/$Pair.java b/gson/src/main/java/com/google/gson/Pair.java similarity index 87% rename from gson/src/main/java/com/google/gson/internal/$Pair.java rename to gson/src/main/java/com/google/gson/Pair.java index 56c5b069..ce5496f1 100644 --- a/gson/src/main/java/com/google/gson/internal/$Pair.java +++ b/gson/src/main/java/com/google/gson/Pair.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.gson.internal; +package com.google.gson; /** * A simple object that holds onto a pair of object references, first and second. @@ -25,11 +25,11 @@ package com.google.gson.internal; * @param * @param */ -public final class $Pair { +final class Pair { public final FIRST first; public final SECOND second; - public $Pair(FIRST first, SECOND second) { + public Pair(FIRST first, SECOND second) { this.first = first; this.second = second; } @@ -42,11 +42,11 @@ public final class $Pair { @Override public boolean equals(Object o) { - if (!(o instanceof $Pair)) { + if (!(o instanceof Pair)) { return false; } - $Pair that = ($Pair) o; + Pair that = (Pair) o; return equal(this.first, that.first) && equal(this.second, that.second); } diff --git a/gson/src/main/java/com/google/gson/ParameterizedTypeHandlerMap.java b/gson/src/main/java/com/google/gson/ParameterizedTypeHandlerMap.java index ff3fd4a2..c44aa2ab 100644 --- a/gson/src/main/java/com/google/gson/ParameterizedTypeHandlerMap.java +++ b/gson/src/main/java/com/google/gson/ParameterizedTypeHandlerMap.java @@ -16,7 +16,6 @@ package com.google.gson; -import com.google.gson.internal.$Pair; import com.google.gson.internal.$Types; import java.lang.reflect.Type; @@ -40,15 +39,15 @@ final class ParameterizedTypeHandlerMap { private static final Logger logger = Logger.getLogger(ParameterizedTypeHandlerMap.class.getName()); private final Map map = new HashMap(); - private final List<$Pair, T>> typeHierarchyList = new ArrayList<$Pair, T>>(); + private final List, T>> typeHierarchyList = new ArrayList, T>>(); private boolean modifiable = true; public synchronized void registerForTypeHierarchy(Class typeOfT, T value) { - $Pair, T> pair = new $Pair, T>(typeOfT, value); + Pair, T> pair = new Pair, T>(typeOfT, value); registerForTypeHierarchy(pair); } - public synchronized void registerForTypeHierarchy($Pair, T> pair) { + public synchronized void registerForTypeHierarchy(Pair, T> pair) { if (!modifiable) { throw new IllegalStateException("Attempted to modify an unmodifiable map."); } @@ -70,7 +69,7 @@ final class ParameterizedTypeHandlerMap { private int getIndexOfAnOverriddenHandler(Class type) { for (int i = typeHierarchyList.size()-1; i >= 0; --i) { - $Pair, T> entry = typeHierarchyList.get(i); + Pair, T> entry = typeHierarchyList.get(i); if (type.isAssignableFrom(entry.first)) { return i; } @@ -100,7 +99,7 @@ final class ParameterizedTypeHandlerMap { // Quite important to traverse the typeHierarchyList from stack bottom first since // we want to register the handlers in the same order to preserve priority order for (int i = other.typeHierarchyList.size()-1; i >= 0; --i) { - $Pair, T> entry = other.typeHierarchyList.get(i); + Pair, T> entry = other.typeHierarchyList.get(i); int index = getIndexOfSpecificHandlerForTypeHierarchy(entry.first); if (index < 0) { registerForTypeHierarchy(entry); @@ -118,7 +117,7 @@ final class ParameterizedTypeHandlerMap { // Quite important to traverse the typeHierarchyList from stack bottom first since // we want to register the handlers in the same order to preserve priority order for (int i = other.typeHierarchyList.size()-1; i >= 0; --i) { - $Pair, T> entry = other.typeHierarchyList.get(i); + Pair, T> entry = other.typeHierarchyList.get(i); registerForTypeHierarchy(entry); } } @@ -152,7 +151,7 @@ final class ParameterizedTypeHandlerMap { } private T getHandlerForTypeHierarchy(Class type) { - for ($Pair, T> entry : typeHierarchyList) { + for (Pair, T> entry : typeHierarchyList) { if (entry.first.isAssignableFrom(type)) { return entry.second; } @@ -186,7 +185,7 @@ final class ParameterizedTypeHandlerMap { public String toString() { StringBuilder sb = new StringBuilder("{mapForTypeHierarchy:{"); boolean first = true; - for ($Pair, T> entry : typeHierarchyList) { + for (Pair, T> entry : typeHierarchyList) { if (first) { first = false; } else { diff --git a/gson/src/main/java/com/google/gson/internal/$Primitives.java b/gson/src/main/java/com/google/gson/Primitives.java similarity index 96% rename from gson/src/main/java/com/google/gson/internal/$Primitives.java rename to gson/src/main/java/com/google/gson/Primitives.java index 0b3ef1aa..6ec5f0d1 100644 --- a/gson/src/main/java/com/google/gson/internal/$Primitives.java +++ b/gson/src/main/java/com/google/gson/Primitives.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.gson.internal; +package com.google.gson; import java.lang.reflect.Type; @@ -22,14 +22,16 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; +import com.google.gson.internal.$Preconditions; + /** * Contains static utility methods pertaining to primitive types and their * corresponding wrapper types. * * @author Kevin Bourrillion */ -public final class $Primitives { - private $Primitives() {} +final class Primitives { + private Primitives() {} /** A map from primitive types to their corresponding wrapper types. */ private static final Map, Class> PRIMITIVE_TO_WRAPPER_TYPE; diff --git a/gson/src/main/java/com/google/gson/ReflectingFieldNavigator.java b/gson/src/main/java/com/google/gson/ReflectingFieldNavigator.java index 1a538a7e..d125049c 100644 --- a/gson/src/main/java/com/google/gson/ReflectingFieldNavigator.java +++ b/gson/src/main/java/com/google/gson/ReflectingFieldNavigator.java @@ -16,7 +16,6 @@ package com.google.gson; import com.google.gson.ObjectNavigator.Visitor; -import com.google.gson.internal.$LruCache; import com.google.gson.internal.$Types; import com.google.gson.internal.$Preconditions; @@ -34,10 +33,10 @@ import java.util.List; * @author Jesse Wilson */ final class ReflectingFieldNavigator { - private static final $LruCache>> classCache = - new $LruCache>>(500); - private static final $LruCache, Field[]> fieldsCache = - new $LruCache, Field[]>(500); + private static final LruCache>> classCache = + new LruCache>>(500); + private static final LruCache, Field[]> fieldsCache = + new LruCache, Field[]>(500); private final ExclusionStrategy exclusionStrategy; diff --git a/gson/src/main/java/com/google/gson/internal/$UnsafeAllocator.java b/gson/src/main/java/com/google/gson/UnsafeAllocator.java similarity index 92% rename from gson/src/main/java/com/google/gson/internal/$UnsafeAllocator.java rename to gson/src/main/java/com/google/gson/UnsafeAllocator.java index c33024ca..d84535dc 100644 --- a/gson/src/main/java/com/google/gson/internal/$UnsafeAllocator.java +++ b/gson/src/main/java/com/google/gson/UnsafeAllocator.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.gson.internal; +package com.google.gson; import java.io.ObjectInputStream; import java.io.ObjectStreamClass; @@ -27,10 +27,10 @@ import java.lang.reflect.Method; * @author Joel Leitch * @author Jesse Wilson */ -public abstract class $UnsafeAllocator { +abstract class UnsafeAllocator { public abstract T newInstance(Class c) throws Exception; - public static $UnsafeAllocator create() { + public static UnsafeAllocator create() { // try JVM // public class Unsafe { // public Object allocateInstance(Class type); @@ -41,7 +41,7 @@ public abstract class $UnsafeAllocator { f.setAccessible(true); final Object unsafe = f.get(null); final Method allocateInstance = unsafeClass.getMethod("allocateInstance", Class.class); - return new $UnsafeAllocator() { + return new UnsafeAllocator() { @Override @SuppressWarnings("unchecked") public T newInstance(Class c) throws Exception { @@ -60,7 +60,7 @@ public abstract class $UnsafeAllocator { final Method newInstance = ObjectInputStream.class .getDeclaredMethod("newInstance", Class.class, Class.class); newInstance.setAccessible(true); - return new $UnsafeAllocator() { + return new UnsafeAllocator() { @Override @SuppressWarnings("unchecked") public T newInstance(Class c) throws Exception { @@ -83,7 +83,7 @@ public abstract class $UnsafeAllocator { final Method newInstance = ObjectStreamClass.class .getDeclaredMethod("newInstance", Class.class, int.class); newInstance.setAccessible(true); - return new $UnsafeAllocator() { + return new UnsafeAllocator() { @Override @SuppressWarnings("unchecked") public T newInstance(Class c) throws Exception { @@ -94,7 +94,7 @@ public abstract class $UnsafeAllocator { } // give up - return new $UnsafeAllocator() { + return new UnsafeAllocator() { @Override public T newInstance(Class c) { throw new UnsupportedOperationException("Cannot allocate " + c); diff --git a/gson/src/test/java/com/google/gson/LruCacheTest.java b/gson/src/test/java/com/google/gson/LruCacheTest.java index 4bcd2500..337aec49 100644 --- a/gson/src/test/java/com/google/gson/LruCacheTest.java +++ b/gson/src/test/java/com/google/gson/LruCacheTest.java @@ -16,13 +16,11 @@ package com.google.gson; -import com.google.gson.internal.$Cache; -import com.google.gson.internal.$LruCache; import junit.framework.TestCase; /** - * Unit test for the {@link $LruCache} class. + * Unit test for the {@link LruCache} class. * * @author Inderjeet Singh * @author Joel Leitch @@ -30,7 +28,7 @@ import junit.framework.TestCase; public class LruCacheTest extends TestCase { public void testCacheHitAndMiss() throws Exception { - $Cache cache = new $LruCache(3); + Cache cache = new LruCache(3); String key = "key1"; assertNull(cache.getElement(key)); @@ -44,7 +42,7 @@ public class LruCacheTest extends TestCase { } public void testCacheKeyOverwrite() throws Exception { - $Cache cache = new $LruCache(3); + Cache cache = new LruCache(3); String key = "key1"; assertNull(cache.getElement(key)); @@ -56,7 +54,7 @@ public class LruCacheTest extends TestCase { } public void testCacheEviction() throws Exception { - $Cache cache = new $LruCache(5); + Cache cache = new LruCache(5); cache.addElement("key1", 1); cache.addElement("key2", 2); diff --git a/gson/src/test/java/com/google/gson/ParamterizedTypeFixtures.java b/gson/src/test/java/com/google/gson/ParamterizedTypeFixtures.java index e687fc14..a533df08 100644 --- a/gson/src/test/java/com/google/gson/ParamterizedTypeFixtures.java +++ b/gson/src/test/java/com/google/gson/ParamterizedTypeFixtures.java @@ -16,7 +16,6 @@ package com.google.gson; -import com.google.gson.internal.$Primitives; import com.google.gson.internal.$Types; import java.lang.reflect.InvocationTargetException; @@ -51,7 +50,7 @@ public class ParamterizedTypeFixtures { private String getExpectedJson(Object obj) { Class clazz = obj.getClass(); - if ($Primitives.isWrapperType($Primitives.wrap(clazz))) { + if (Primitives.isWrapperType(Primitives.wrap(clazz))) { return obj.toString(); } else if (obj.getClass().equals(String.class)) { return "\"" + obj.toString() + "\""; @@ -127,7 +126,7 @@ public class ParamterizedTypeFixtures { @SuppressWarnings("unchecked") public static String getExpectedJson(MyParameterizedType obj) { Class clazz = (Class) obj.value.getClass(); - boolean addQuotes = !clazz.isArray() && !$Primitives.unwrap(clazz).isPrimitive(); + boolean addQuotes = !clazz.isArray() && !Primitives.unwrap(clazz).isPrimitive(); StringBuilder sb = new StringBuilder("{\""); sb.append(obj.value.getClass().getSimpleName()).append("\":"); if (addQuotes) { @@ -156,7 +155,7 @@ public class ParamterizedTypeFixtures { Class rawType = $Types.getRawType(genericClass); String className = rawType.getSimpleName(); T value = (T) json.getAsJsonObject().get(className).getAsObject(); - if ($Primitives.isPrimitive(genericClass)) { + if (Primitives.isPrimitive(genericClass)) { PrimitiveTypeAdapter typeAdapter = new PrimitiveTypeAdapter(); value = (T) typeAdapter.adaptType(value, rawType); } diff --git a/gson/src/test/java/com/google/gson/PrimitiveTypeAdapter.java b/gson/src/test/java/com/google/gson/PrimitiveTypeAdapter.java index 5e453c28..801697c2 100644 --- a/gson/src/test/java/com/google/gson/PrimitiveTypeAdapter.java +++ b/gson/src/test/java/com/google/gson/PrimitiveTypeAdapter.java @@ -16,7 +16,6 @@ package com.google.gson; -import com.google.gson.internal.$Primitives; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -31,8 +30,8 @@ final class PrimitiveTypeAdapter { @SuppressWarnings("unchecked") public T adaptType(Object from, Class to) { - Class aClass = $Primitives.wrap(to); - if ($Primitives.isWrapperType(aClass)) { + Class aClass = Primitives.wrap(to); + if (Primitives.isWrapperType(aClass)) { if (aClass == Character.class) { String value = from.toString(); if (value.length() == 1) {