From 8f456831d4d3bfa00f0fc72191480cdc2fb828dd Mon Sep 17 00:00:00 2001 From: Inderjeet Singh Date: Wed, 11 Mar 2009 21:53:02 +0000 Subject: [PATCH] Fixed Issue 104 by making FieldNamingStrategy to be public and allowing FieldNamingStrategy to be set in GsonBuilder --- .../main/java/com/google/gson/FieldNamingStrategy.java | 4 +++- gson/src/main/java/com/google/gson/GsonBuilder.java | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/gson/src/main/java/com/google/gson/FieldNamingStrategy.java b/gson/src/main/java/com/google/gson/FieldNamingStrategy.java index 59bf3325..0ae6ea4a 100644 --- a/gson/src/main/java/com/google/gson/FieldNamingStrategy.java +++ b/gson/src/main/java/com/google/gson/FieldNamingStrategy.java @@ -24,14 +24,16 @@ import java.lang.reflect.Field; * declaration rules. For example, Java does not support "-" characters in a field name. * * @author Joel Leitch + * @since 1.3 */ -interface FieldNamingStrategy { +public interface FieldNamingStrategy { /** * Translates the field name into its JSON field name representation. * * @param f the field object that we are translating * @return the translated field name. + * @since 1.3 */ public String translateName(Field f); } diff --git a/gson/src/main/java/com/google/gson/GsonBuilder.java b/gson/src/main/java/com/google/gson/GsonBuilder.java index f92e4814..32119e4d 100644 --- a/gson/src/main/java/com/google/gson/GsonBuilder.java +++ b/gson/src/main/java/com/google/gson/GsonBuilder.java @@ -191,11 +191,13 @@ public final class GsonBuilder { * Configures Gson to apply a specific naming policy strategy to an object's field during * serialization and deserialization. * - * @param fieldNamingPolicy the actual naming strategy to apply to the fields + * @param fieldNamingStrategy the actual naming strategy to apply to the fields * @return a reference to this {@code GsonBuilder} object to fulfill the "Builder" pattern + * @since 1.3 */ - private GsonBuilder setFieldNamingStrategy(FieldNamingStrategy fieldNamingPolicy) { - this.fieldNamingPolicy = new SerializedNameAnnotationInterceptingNamingPolicy(fieldNamingPolicy); + public GsonBuilder setFieldNamingStrategy(FieldNamingStrategy fieldNamingStrategy) { + this.fieldNamingPolicy = + new SerializedNameAnnotationInterceptingNamingPolicy(fieldNamingStrategy); return this; }