From 4bd261ae060edac514882b4f9026a7aba4c7ecaa Mon Sep 17 00:00:00 2001 From: Inderjeet Singh Date: Thu, 7 Apr 2011 17:41:35 +0000 Subject: [PATCH] Made FieldNamingStrategy2 and its corresponding builder method package-private. --- gson/src/main/java/com/google/gson/FieldAttributes.java | 2 +- .../src/main/java/com/google/gson/FieldNamingStrategy.java | 2 -- .../main/java/com/google/gson/FieldNamingStrategy2.java | 2 +- .../java/com/google/gson/FieldNamingStrategy2Adapter.java | 5 ++--- gson/src/main/java/com/google/gson/GsonBuilder.java | 7 +------ .../java/com/google/gson/JsonDeserializationVisitor.java | 2 +- .../SerializedNameAnnotationInterceptingNamingPolicy.java | 2 +- .../com/google/gson/FieldNamingStrategy2AdapterTest.java | 1 - .../java/com/google/gson/functional/NamingPolicyTest.java | 1 - 9 files changed, 7 insertions(+), 17 deletions(-) diff --git a/gson/src/main/java/com/google/gson/FieldAttributes.java b/gson/src/main/java/com/google/gson/FieldAttributes.java index 511c2cbd..be44526e 100644 --- a/gson/src/main/java/com/google/gson/FieldAttributes.java +++ b/gson/src/main/java/com/google/gson/FieldAttributes.java @@ -214,7 +214,7 @@ public final class FieldAttributes { } /** - * @deprecated remove this when {@link FieldNamingStrategy} is deleted. + * remove this when {@link FieldNamingStrategy} is deleted. */ @Deprecated Field getFieldObject() { diff --git a/gson/src/main/java/com/google/gson/FieldNamingStrategy.java b/gson/src/main/java/com/google/gson/FieldNamingStrategy.java index 2a22cb0e..9be453ad 100644 --- a/gson/src/main/java/com/google/gson/FieldNamingStrategy.java +++ b/gson/src/main/java/com/google/gson/FieldNamingStrategy.java @@ -26,9 +26,7 @@ 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 cca69a6b..5fcd1c04 100644 --- a/gson/src/main/java/com/google/gson/FieldNamingStrategy2.java +++ b/gson/src/main/java/com/google/gson/FieldNamingStrategy2.java @@ -27,7 +27,7 @@ package com.google.gson; * * @since 1.7 */ -public interface FieldNamingStrategy2 { +interface FieldNamingStrategy2 { /** * Translates the field name into its JSON field name representation. diff --git a/gson/src/main/java/com/google/gson/FieldNamingStrategy2Adapter.java b/gson/src/main/java/com/google/gson/FieldNamingStrategy2Adapter.java index 88b81c5f..f537b87d 100644 --- a/gson/src/main/java/com/google/gson/FieldNamingStrategy2Adapter.java +++ b/gson/src/main/java/com/google/gson/FieldNamingStrategy2Adapter.java @@ -19,17 +19,16 @@ package com.google.gson; import com.google.gson.internal.$Gson$Preconditions; /** - * Adapts the old "deprecated" FieldNamingStrategy to the new {@link FieldNamingStrategy2} + * Adapts the old FieldNamingStrategy to the new {@link FieldNamingStrategy2} * type. * * @author Inderjeet Singh * @author Joel Leitch */ -@SuppressWarnings("deprecation") final class FieldNamingStrategy2Adapter implements FieldNamingStrategy2 { private final FieldNamingStrategy adaptee; - public FieldNamingStrategy2Adapter(FieldNamingStrategy adaptee) { + FieldNamingStrategy2Adapter(FieldNamingStrategy adaptee) { this.adaptee = $Gson$Preconditions.checkNotNull(adaptee); } diff --git a/gson/src/main/java/com/google/gson/GsonBuilder.java b/gson/src/main/java/com/google/gson/GsonBuilder.java index 83eb7114..3af74d66 100644 --- a/gson/src/main/java/com/google/gson/GsonBuilder.java +++ b/gson/src/main/java/com/google/gson/GsonBuilder.java @@ -319,11 +319,7 @@ 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)); } @@ -334,9 +330,8 @@ 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 */ - public GsonBuilder setFieldNamingStrategy(FieldNamingStrategy2 fieldNamingStrategy) { + GsonBuilder setFieldNamingStrategy(FieldNamingStrategy2 fieldNamingStrategy) { this.fieldNamingPolicy = new SerializedNameAnnotationInterceptingNamingPolicy(fieldNamingStrategy); return this; diff --git a/gson/src/main/java/com/google/gson/JsonDeserializationVisitor.java b/gson/src/main/java/com/google/gson/JsonDeserializationVisitor.java index 5403884a..a928fcba 100644 --- a/gson/src/main/java/com/google/gson/JsonDeserializationVisitor.java +++ b/gson/src/main/java/com/google/gson/JsonDeserializationVisitor.java @@ -40,7 +40,7 @@ abstract class JsonDeserializationVisitor implements ObjectNavigator.Visitor protected final JsonDeserializationContext context; protected boolean constructed; - public JsonDeserializationVisitor(JsonElement json, Type targetType, + JsonDeserializationVisitor(JsonElement json, Type targetType, ObjectNavigator objectNavigator, FieldNamingStrategy2 fieldNamingPolicy, ObjectConstructor objectConstructor, ParameterizedTypeHandlerMap> deserializers, diff --git a/gson/src/main/java/com/google/gson/SerializedNameAnnotationInterceptingNamingPolicy.java b/gson/src/main/java/com/google/gson/SerializedNameAnnotationInterceptingNamingPolicy.java index da7ada1f..b8a500ca 100644 --- a/gson/src/main/java/com/google/gson/SerializedNameAnnotationInterceptingNamingPolicy.java +++ b/gson/src/main/java/com/google/gson/SerializedNameAnnotationInterceptingNamingPolicy.java @@ -35,7 +35,7 @@ final class SerializedNameAnnotationInterceptingNamingPolicy implements FieldNam private static final JsonFieldNameValidator fieldNameValidator = new JsonFieldNameValidator(); private final FieldNamingStrategy2 delegate; - public SerializedNameAnnotationInterceptingNamingPolicy(FieldNamingStrategy2 delegate) { + SerializedNameAnnotationInterceptingNamingPolicy(FieldNamingStrategy2 delegate) { this.delegate = delegate; } diff --git a/gson/src/test/java/com/google/gson/FieldNamingStrategy2AdapterTest.java b/gson/src/test/java/com/google/gson/FieldNamingStrategy2AdapterTest.java index 99f175e7..639a47ee 100644 --- a/gson/src/test/java/com/google/gson/FieldNamingStrategy2AdapterTest.java +++ b/gson/src/test/java/com/google/gson/FieldNamingStrategy2AdapterTest.java @@ -37,7 +37,6 @@ public class FieldNamingStrategy2AdapterTest extends TestCase { new FieldAttributes(String.class, field, String.class))); } - @SuppressWarnings("deprecation") private static class UpperCaseNamingStrategy implements FieldNamingStrategy { public String translateName(Field f) { return f.getName().toUpperCase(); diff --git a/gson/src/test/java/com/google/gson/functional/NamingPolicyTest.java b/gson/src/test/java/com/google/gson/functional/NamingPolicyTest.java index 242326fd..07f3c231 100644 --- a/gson/src/test/java/com/google/gson/functional/NamingPolicyTest.java +++ b/gson/src/test/java/com/google/gson/functional/NamingPolicyTest.java @@ -33,7 +33,6 @@ import junit.framework.TestCase; * @author Inderjeet Singh * @author Joel Leitch */ -@SuppressWarnings("deprecation") public class NamingPolicyTest extends TestCase { private GsonBuilder builder;