From caef762530f61de5c41b497200d1b98019b073a1 Mon Sep 17 00:00:00 2001 From: Inderjeet Singh Date: Thu, 5 Nov 2015 14:03:51 -0800 Subject: [PATCH] added factory fields for consistency --- gson/src/main/java/com/google/gson/Gson.java | 6 +++--- .../java/com/google/gson/internal/bind/TypeAdapters.java | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gson/src/main/java/com/google/gson/Gson.java b/gson/src/main/java/com/google/gson/Gson.java index 0e6f46af..303e2510 100644 --- a/gson/src/main/java/com/google/gson/Gson.java +++ b/gson/src/main/java/com/google/gson/Gson.java @@ -221,10 +221,10 @@ public final class Gson { factories.add(TypeAdapters.newFactory(float.class, Float.class, floatAdapter(serializeSpecialFloatingPointValues))); factories.add(TypeAdapters.NUMBER_FACTORY); - factories.add(TypeAdapters.newFactory(AtomicInteger.class, TypeAdapters.ATOMIC_INTEGER)); - factories.add(TypeAdapters.newFactory(AtomicBoolean.class, TypeAdapters.ATOMIC_BOOLEAN)); + factories.add(TypeAdapters.ATOMIC_INTEGER_FACTORY); + factories.add(TypeAdapters.ATOMIC_BOOLEAN_FACTORY); factories.add(TypeAdapters.newFactory(AtomicLong.class, atomicLongAdapter(longAdapter))); - factories.add(TypeAdapters.newFactory(AtomicIntegerArray.class, TypeAdapters.ATOMIC_INTEGER_ARRAY)); + factories.add(TypeAdapters.ATOMIC_INTEGER_ARRAY_FACTORY); factories.add(TypeAdapters.CHARACTER_FACTORY); factories.add(TypeAdapters.STRING_BUILDER_FACTORY); factories.add(TypeAdapters.STRING_BUFFER_FACTORY); diff --git a/gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java b/gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java index a7c7182d..d284dd5b 100644 --- a/gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java +++ b/gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java @@ -268,6 +268,8 @@ public final class TypeAdapters { out.value(value.get()); } }.nullSafe(); + public static final TypeAdapterFactory ATOMIC_INTEGER_FACTORY = + newFactory(AtomicInteger.class, TypeAdapters.ATOMIC_INTEGER); public static final TypeAdapter ATOMIC_BOOLEAN = new TypeAdapter() { @Override public AtomicBoolean read(JsonReader in) throws IOException { @@ -277,6 +279,8 @@ public final class TypeAdapters { out.value(value.get()); } }.nullSafe(); + public static final TypeAdapterFactory ATOMIC_BOOLEAN_FACTORY = + newFactory(AtomicBoolean.class, TypeAdapters.ATOMIC_BOOLEAN); public static final TypeAdapter ATOMIC_INTEGER_ARRAY = new TypeAdapter() { @Override public AtomicIntegerArray read(JsonReader in) throws IOException { @@ -306,6 +310,8 @@ public final class TypeAdapters { out.endArray(); } }.nullSafe(); + public static final TypeAdapterFactory ATOMIC_INTEGER_ARRAY_FACTORY = + newFactory(AtomicIntegerArray.class, TypeAdapters.ATOMIC_INTEGER_ARRAY); public static final TypeAdapter LONG = new TypeAdapter() { @Override