List of usage examples for com.google.gson FieldNamingPolicy IDENTITY
FieldNamingPolicy IDENTITY
To view the source code for com.google.gson FieldNamingPolicy IDENTITY.
Click Source Link
From source file:org.gdg.frisbee.android.api.GroupDirectory.java
License:Apache License
public ApiRequest getChapterEventList(final DateTime start, final DateTime end, final String chapterId, Response.Listener<ArrayList<Event>> successListener, Response.ErrorListener errorListener) { ArrayList<NameValuePair> params = new ArrayList<>(); params.add(new NameValuePair() { @Override/* ww w . j a v a2s. c o m*/ public String getName() { return "group"; } @Override public String getValue() { return chapterId; } }); params.add(new NameValuePair() { @Override public String getName() { return "start"; } @Override public String getValue() { return "" + (int) (start.getMillis() / 1000); } }); if (end != null) { params.add(new NameValuePair() { @Override public String getName() { return "end"; } @Override public String getValue() { return "" + (int) (end.getMillis() / 1000); } }); } params.add(new NameValuePair() { @Override public String getName() { return "_"; } @Override public String getValue() { return "" + (int) (new DateTime().getMillis() / 1000); } }); Type type = new TypeToken<ArrayList<Event>>() { }.getType(); String url = CHAPTER_CALENDAR_URL; url += "?" + URLEncodedUtils.format(params, "UTF-8"); GsonRequest<Void, ArrayList<Event>> eventReq = new GsonRequest<>(Request.Method.GET, url, type, successListener, errorListener, GsonRequest.getGson(FieldNamingPolicy.IDENTITY)); return new ApiRequest(eventReq); }
From source file:org.gdg.frisbee.android.api.GroupDirectory.java
License:Apache License
public ApiRequest getTaggedEventList(final DateTime start, final DateTime end, final String tag, Response.Listener<PagedList<TaggedEvent>> successListener, Response.ErrorListener errorListener) { ArrayList<NameValuePair> params = new ArrayList<>(); params.add(new NameValuePair() { @Override/*from w w w.j a v a2 s.co m*/ public String getName() { return "start"; } @Override public String getValue() { return "" + (int) (start.getMillis() / 1000); } }); if (end != null) { params.add(new NameValuePair() { @Override public String getName() { return "end"; } @Override public String getValue() { return "" + (int) (end.getMillis() / 1000); } }); } params.add(new NameValuePair() { @Override public String getName() { return "_"; } @Override public String getValue() { return "" + (int) (new DateTime().getMillis() / 1000); } }); params.add(new NameValuePair() { @Override public String getName() { return "perpage"; } @Override public String getValue() { return "1000"; } }); Type type = new TypeToken<PagedList<TaggedEvent>>() { }.getType(); String url = TAGGED_EVENTS_URL + tag; url += "?" + URLEncodedUtils.format(params, "UTF-8"); GsonRequest<Void, PagedList<TaggedEvent>> eventReq = new GsonRequest<>(Request.Method.GET, url, type, successListener, errorListener, GsonRequest.getGson(FieldNamingPolicy.IDENTITY, new ZuluDateTimeDeserializer())); return new ApiRequest(eventReq); }
From source file:org.gdg.frisbee.android.api.GroupDirectory.java
License:Apache License
public ApiRequest getTaggedEventUpcomingList(final String tag, Response.Listener<PagedList<TaggedEvent>> successListener, Response.ErrorListener errorListener) { ArrayList<NameValuePair> params = new ArrayList<>(); params.add(new NameValuePair() { @Override//from w w w . j a v a 2 s . c o m public String getName() { return "_"; } @Override public String getValue() { return "" + (int) (new DateTime().getMillis() / 1000); } }); params.add(new NameValuePair() { @Override public String getName() { return "perpage"; } @Override public String getValue() { return "1000"; } }); Type type = new TypeToken<PagedList<TaggedEvent>>() { }.getType(); String url = String.format(TAGGED_EVENTS_URL_UPCOMING, tag); url += "?" + URLEncodedUtils.format(params, "UTF-8"); GsonRequest<Void, PagedList<TaggedEvent>> eventReq = new GsonRequest<>(Request.Method.GET, url, type, successListener, errorListener, GsonRequest.getGson(FieldNamingPolicy.IDENTITY, new ZuluDateTimeDeserializer())); return new ApiRequest(eventReq); }
From source file:org.gdg.frisbee.android.app.App.java
License:Apache License
public GdgXHub getGdgXHub() { if (hubInstance == null) { hubInstance = new RestAdapter.Builder().setEndpoint(GdgXHub.BASE_URL) .setConverter(new GsonConverter( Utils.getGson(FieldNamingPolicy.IDENTITY, new ZuluDateTimeDeserializer()))) .build().create(GdgXHub.class); }// w w w . j av a 2 s. c om return hubInstance; }
From source file:org.immutables.gson.adapter.FieldNamingTranslator.java
License:Apache License
private static FieldNamingStrategy namingStrategyFrom(Gson gson) { Object factories = readPrivateField(gson, "factories"); if (factories instanceof Iterable<?>) { for (Object factory : (Iterable<?>) factories) { if (factory instanceof com.google.gson.internal.bind.ReflectiveTypeAdapterFactory) { Object strategy = readPrivateField(factory, "fieldNamingPolicy"); if (strategy instanceof FieldNamingStrategy) { return (FieldNamingStrategy) strategy; }/*from ww w . j a va 2s . c o m*/ } } } complainOnce(); return FieldNamingPolicy.IDENTITY; }
From source file:org.lastaflute.core.json.engine.GsonJsonEngine.java
License:Apache License
protected FieldNamingPolicy deriveFieldNamingPolicy(JsonFieldNaming naming) { final FieldNamingPolicy policy; if (naming == JsonFieldNaming.IDENTITY) { policy = FieldNamingPolicy.IDENTITY; } else if (naming == JsonFieldNaming.CAMEL_TO_LOWER_SNAKE) { policy = FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES; } else {/*from w ww .j a v a 2 s . com*/ throw new IllegalStateException("Unknown field naming: " + naming); } return policy; }
From source file:org.lastaflute.doc.generator.ActionDocumentGenerator.java
License:Apache License
protected String adjustFieldName(Class<?> clazz, Field field) { // TODO p1us2er0 judge accurately in adjustFieldName() (2017/04/20) if (clazz.getSimpleName().endsWith("Form")) { return field.getName(); }/*from www. ja v a 2 s . c o m*/ return getApplicationJsonMappingOption().flatMap(jsonMappingOption -> { return jsonMappingOption.getFieldNaming().map(naming -> { if (naming == JsonFieldNaming.IDENTITY) { return FieldNamingPolicy.IDENTITY.translateName(field); } else if (naming == JsonFieldNaming.CAMEL_TO_LOWER_SNAKE) { return FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES.translateName(field); } else { return field.getName(); } }); }).orElse(field.getName()); }
From source file:org.openhab.binding.toon.internal.ToonApiClient.java
License:Open Source License
private GsonBuilder createGsonBuilder() { GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.IDENTITY); return gsonBuilder; }
From source file:rest.GroupService.java
/** * Creates a new instance of GenericResource */ public GroupService() { gson = new GsonBuilder().setPrettyPrinting().setFieldNamingPolicy(FieldNamingPolicy.IDENTITY).create(); }
From source file:REST.MemberResource.java
/** * Creates a new instance of ApiResource */ public MemberResource() { gson = new GsonBuilder().setPrettyPrinting().setFieldNamingPolicy(FieldNamingPolicy.IDENTITY).create(); }