com.gocardless.http.GsonFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gocardless-pro Show documentation
Show all versions of gocardless-pro Show documentation
Client library for accessing the GoCardless Pro API
package com.gocardless.http;
import static com.google.gson.FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES;
import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
final class GsonFactory {
private GsonFactory() {
// blank to prevent instantiation
}
static Gson build() {
return new GsonBuilder().setFieldNamingPolicy(LOWER_CASE_WITH_UNDERSCORES)
.addSerializationExclusionStrategy(new PathParamExclusionStrategy())
.registerTypeAdapterFactory(new GCEnumTypeAdapterFactory()).create();
}
private static class PathParamExclusionStrategy implements ExclusionStrategy {
@Override
public boolean shouldSkipField(FieldAttributes f) {
return f.getAnnotation(PathParam.class) != null;
}
@Override
public boolean shouldSkipClass(Class> clazz) {
return false;
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy