From fb7bd7b1b7bbc0ba75b74c2861807852cf43b30d Mon Sep 17 00:00:00 2001 From: Joel Leitch Date: Sat, 22 Jan 2011 22:27:30 +0000 Subject: [PATCH] Deprecate the old FieldNamingStrategy interface and open up the FieldNamingStrategy2 instead to take its place. --- .../src/main/java/com/google/gson/FieldNamingStrategy.java | 2 ++ .../main/java/com/google/gson/FieldNamingStrategy2.java | 5 +++-- gson/src/main/java/com/google/gson/GsonBuilder.java | 7 ++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/gson/src/main/java/com/google/gson/FieldNamingStrategy.java b/gson/src/main/java/com/google/gson/FieldNamingStrategy.java index 9be453ad..2a22cb0e 100644 --- a/gson/src/main/java/com/google/gson/FieldNamingStrategy.java +++ b/gson/src/main/java/com/google/gson/FieldNamingStrategy.java @@ -26,7 +26,9 @@ import java.lang.reflect.Field; * @author Inderjeet Singh * @author Joel Leitch * @since 1.3 + * @deprecated use the {@link FieldNamingStrategy2} instead */ +@Deprecated public interface FieldNamingStrategy { /** diff --git a/gson/src/main/java/com/google/gson/FieldNamingStrategy2.java b/gson/src/main/java/com/google/gson/FieldNamingStrategy2.java index 78dc9c87..cca69a6b 100644 --- a/gson/src/main/java/com/google/gson/FieldNamingStrategy2.java +++ b/gson/src/main/java/com/google/gson/FieldNamingStrategy2.java @@ -24,15 +24,16 @@ package com.google.gson; * * @author Inderjeet Singh * @author Joel Leitch + * + * @since 1.7 */ -interface FieldNamingStrategy2 { +public interface FieldNamingStrategy2 { /** * Translates the field name into its JSON field name representation. * * @param f the field that is being translated * @return the translated field name. - * @since 1.3 */ public String translateName(FieldAttributes f); } diff --git a/gson/src/main/java/com/google/gson/GsonBuilder.java b/gson/src/main/java/com/google/gson/GsonBuilder.java index 452c26e9..5fbe3b2e 100644 --- a/gson/src/main/java/com/google/gson/GsonBuilder.java +++ b/gson/src/main/java/com/google/gson/GsonBuilder.java @@ -216,7 +216,11 @@ public final class GsonBuilder { * @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 + * @deprecated convert {@code fieldNamingStrategy} to a implement from + * {@link FieldNamingStrategy2} and call {@link #setFieldNamingStrategy(FieldNamingStrategy2)} + * instead. */ + @Deprecated public GsonBuilder setFieldNamingStrategy(FieldNamingStrategy fieldNamingStrategy) { return setFieldNamingStrategy(new FieldNamingStrategy2Adapter(fieldNamingStrategy)); } @@ -227,8 +231,9 @@ public final class GsonBuilder { * * @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.7 */ - GsonBuilder setFieldNamingStrategy(FieldNamingStrategy2 fieldNamingStrategy) { + public GsonBuilder setFieldNamingStrategy(FieldNamingStrategy2 fieldNamingStrategy) { this.fieldNamingPolicy = new SerializedNameAnnotationInterceptingNamingPolicy(fieldNamingStrategy); return this;