Code example for GsonBuilder

Methods: createregisterTypeAdaptersetPrettyPrinting

0
 */ 
@Service 
public final class GoogleGsonSerializerHelper { 
 
    public Gson createGsonBuilder(final boolean prettyPrint) {
        final GsonBuilder builder = new GsonBuilder();
        builder.registerTypeAdapter(LocalDate.class, new JodaLocalDateAdapter());
        builder.registerTypeAdapter(DateTime.class, new JodaDateTimeAdapter());
        builder.registerTypeAdapter(MonthDay.class, new JodaMonthDayAdapter());
        if (prettyPrint) {
            builder.setPrettyPrinting();
        } 
        return builder.create();
    } 
 
    public Gson createGsonBuilderWithParameterExclusionSerializationStrategy(final Set<String> supportedParameters,
            final boolean prettyPrint, final Set<String> responseParameters) {
 
        final Set<String> parameterNamesToSkip = new HashSet<String>();