From bc68d7293c437fd2e5bbcd4bffff4414b03b74a6 Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Wed, 23 Nov 2011 13:39:06 +0000 Subject: [PATCH] Comment clean up. --- gson/src/main/java/com/google/gson/Gson.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/gson/src/main/java/com/google/gson/Gson.java b/gson/src/main/java/com/google/gson/Gson.java index bba53fce..fba8ccdb 100644 --- a/gson/src/main/java/com/google/gson/Gson.java +++ b/gson/src/main/java/com/google/gson/Gson.java @@ -196,6 +196,8 @@ public final class Gson { ConstructorConstructor constructorConstructor = new ConstructorConstructor(); List factories = new ArrayList(); + + // built-in type adapters that cannot be overridden factories.add(TypeAdapters.STRING_FACTORY); factories.add(TypeAdapters.INTEGER_FACTORY); factories.add(TypeAdapters.BOOLEAN_FACTORY); @@ -217,10 +219,10 @@ public final class Gson { factories.add(TypeAdapters.JSON_ELEMENT_FACTORY); factories.add(ObjectTypeAdapter.FACTORY); - for (TypeAdapter.Factory factory : typeAdapterFactories) { - factories.add(factory); - } + // user's type adapters + factories.addAll(typeAdapterFactories); + // built-in type adapters that can be overridden factories.add(new CollectionTypeAdapterFactory(constructorConstructor)); factories.add(TypeAdapters.URL_FACTORY); factories.add(TypeAdapters.URI_FACTORY); @@ -255,7 +257,7 @@ public final class Gson { } @Override public void write(JsonWriter writer, Number value) throws IOException { if (value == null) { - writer.nullValue(); // TODO: better policy here? + writer.nullValue(); return; } double doubleValue = value.doubleValue(); @@ -279,7 +281,7 @@ public final class Gson { } @Override public void write(JsonWriter writer, Number value) throws IOException { if (value == null) { - writer.nullValue(); // TODO: better policy here? + writer.nullValue(); return; } float floatValue = value.floatValue(); @@ -311,7 +313,7 @@ public final class Gson { } @Override public void write(JsonWriter writer, Number value) throws IOException { if (value == null) { - writer.nullValue(); // TODO: better policy here? + writer.nullValue(); return; } writer.value(value.toString()); @@ -838,9 +840,6 @@ public final class Gson { StringBuilder sb = new StringBuilder("{") .append("serializeNulls:").append(serializeNulls) .append("factories:").append(factories) - // using the name instanceCreator instead of ObjectConstructor since the users of Gson are - // more familiar with the concept of Instance Creators. Moreover, the objectConstructor is - // just a utility class around instance creators, and its toString() only displays them. .append(",instanceCreators:").append(constructorConstructor) .append("}"); return sb.toString();