Fixed Issue 104 by making FieldNamingStrategy to be public and allowing FieldNamingStrategy to be set in GsonBuilder

This commit is contained in:
Inderjeet Singh 2009-03-11 21:53:02 +00:00
parent 809e3b5e21
commit 8f456831d4
2 changed files with 8 additions and 4 deletions

View File

@ -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);
}

View File

@ -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;
}