Deprecate the old FieldNamingStrategy interface and open up the FieldNamingStrategy2 instead to take its place.
This commit is contained in:
parent
b883f8f4aa
commit
fb7bd7b1b7
@ -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 {
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user