Comment clean up.

This commit is contained in:
Jesse Wilson 2011-11-23 13:39:06 +00:00
parent 9a80d095d9
commit bc68d7293c

View File

@ -196,6 +196,8 @@ public final class Gson {
ConstructorConstructor constructorConstructor = new ConstructorConstructor(); ConstructorConstructor constructorConstructor = new ConstructorConstructor();
List<TypeAdapter.Factory> factories = new ArrayList<TypeAdapter.Factory>(); List<TypeAdapter.Factory> factories = new ArrayList<TypeAdapter.Factory>();
// built-in type adapters that cannot be overridden
factories.add(TypeAdapters.STRING_FACTORY); factories.add(TypeAdapters.STRING_FACTORY);
factories.add(TypeAdapters.INTEGER_FACTORY); factories.add(TypeAdapters.INTEGER_FACTORY);
factories.add(TypeAdapters.BOOLEAN_FACTORY); factories.add(TypeAdapters.BOOLEAN_FACTORY);
@ -217,10 +219,10 @@ public final class Gson {
factories.add(TypeAdapters.JSON_ELEMENT_FACTORY); factories.add(TypeAdapters.JSON_ELEMENT_FACTORY);
factories.add(ObjectTypeAdapter.FACTORY); factories.add(ObjectTypeAdapter.FACTORY);
for (TypeAdapter.Factory factory : typeAdapterFactories) { // user's type adapters
factories.add(factory); factories.addAll(typeAdapterFactories);
}
// built-in type adapters that can be overridden
factories.add(new CollectionTypeAdapterFactory(constructorConstructor)); factories.add(new CollectionTypeAdapterFactory(constructorConstructor));
factories.add(TypeAdapters.URL_FACTORY); factories.add(TypeAdapters.URL_FACTORY);
factories.add(TypeAdapters.URI_FACTORY); factories.add(TypeAdapters.URI_FACTORY);
@ -255,7 +257,7 @@ public final class Gson {
} }
@Override public void write(JsonWriter writer, Number value) throws IOException { @Override public void write(JsonWriter writer, Number value) throws IOException {
if (value == null) { if (value == null) {
writer.nullValue(); // TODO: better policy here? writer.nullValue();
return; return;
} }
double doubleValue = value.doubleValue(); double doubleValue = value.doubleValue();
@ -279,7 +281,7 @@ public final class Gson {
} }
@Override public void write(JsonWriter writer, Number value) throws IOException { @Override public void write(JsonWriter writer, Number value) throws IOException {
if (value == null) { if (value == null) {
writer.nullValue(); // TODO: better policy here? writer.nullValue();
return; return;
} }
float floatValue = value.floatValue(); float floatValue = value.floatValue();
@ -311,7 +313,7 @@ public final class Gson {
} }
@Override public void write(JsonWriter writer, Number value) throws IOException { @Override public void write(JsonWriter writer, Number value) throws IOException {
if (value == null) { if (value == null) {
writer.nullValue(); // TODO: better policy here? writer.nullValue();
return; return;
} }
writer.value(value.toString()); writer.value(value.toString());
@ -838,9 +840,6 @@ public final class Gson {
StringBuilder sb = new StringBuilder("{") StringBuilder sb = new StringBuilder("{")
.append("serializeNulls:").append(serializeNulls) .append("serializeNulls:").append(serializeNulls)
.append("factories:").append(factories) .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(",instanceCreators:").append(constructorConstructor)
.append("}"); .append("}");
return sb.toString(); return sb.toString();