Java 类com.google.gson.FieldNamingStrategy 实例源码

项目:unitimes    文件:EventsExportEventsToJSON.java   
@Override
protected void print(ExportHelper helper, EventLookupRpcRequest request, List<EventInterface> events, int eventCookieFlags, EventMeetingSortBy sort, boolean asc) throws IOException {
    helper.setup("application/json", reference(), false);

    Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
        @Override
        public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) {
            return new JsonPrimitive(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(src));
        }
    })
    .setFieldNamingStrategy(new FieldNamingStrategy() {
        Pattern iPattern = Pattern.compile("i([A-Z])(.*)");
        @Override
        public String translateName(Field f) {
            Matcher matcher = iPattern.matcher(f.getName());
            if (matcher.matches())
                return matcher.group(1).toLowerCase() + matcher.group(2);
            else
                return f.getName();
        }
    })
    .setPrettyPrinting().create();

    helper.getWriter().write(gson.toJson(events));
}
项目:unitime    文件:EventsExportEventsToJSON.java   
@Override
protected void print(ExportHelper helper, EventLookupRpcRequest request, List<EventInterface> events, int eventCookieFlags, EventMeetingSortBy sort, boolean asc) throws IOException {
    helper.setup("application/json", reference(), false);

    Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
        @Override
        public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) {
            return new JsonPrimitive(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(src));
        }
    })
    .setFieldNamingStrategy(new FieldNamingStrategy() {
        Pattern iPattern = Pattern.compile("i([A-Z])(.*)");
        @Override
        public String translateName(Field f) {
            Matcher matcher = iPattern.matcher(f.getName());
            if (matcher.matches())
                return matcher.group(1).toLowerCase() + matcher.group(2);
            else
                return f.getName();
        }
    })
    .setPrettyPrinting().create();

    helper.getWriter().write(gson.toJson(events));
}
项目:ServiceCOLDCache    文件:TrackerClient.java   
protected HttpEntity createEntity(Object pojo) {
    Gson gson = new GsonBuilder().serializeNulls()
            .setFieldNamingStrategy(new FieldNamingStrategy() {

                @Override
                public String translateName(Field field) {
                    String name = field.getName();
                    if (name.startsWith("m_")) {
                        name = name.substring(2);
                    }
                    return name;
                }
            }).create();
    return new StringEntity(gson.toJson(pojo), ContentType.APPLICATION_JSON);
}
项目:teamcity-build-scan-plugin    文件:SlackPayloadSerializer.java   
@NotNull
static SlackPayloadSerializer create() {
    Map<Field, FieldNamingStrategy> customNamings = new HashMap<>();
    customNamings.put(declaredField(SlackPayload.Attachment.Field.class, "isShort"), f -> "short");

    Gson gson = new GsonBuilder()
        .setFieldNamingStrategy(new FieldNamingStrategyDelegate(customNamings, FieldNamingPolicy.IDENTITY))
        .disableHtmlEscaping()
        .setPrettyPrinting()
        .create();

    return new SlackPayloadSerializer(gson);
}
项目:graphql-spqr    文件:TestSchemaGenerator.java   
private GsonValueMapperFactory clone(GsonValueMapperFactory valueMapperFactory) {
    TypeInfoGenerator infoGen = getFieldValue(valueMapperFactory, "typeInfoGenerator");
    GsonValueMapperFactory.Configurer configurer = getFieldValue(valueMapperFactory, "configurer");
    FieldNamingStrategy fieldNamingStrategy = getFieldValue(valueMapperFactory, "fieldNamingStrategy");
    return GsonValueMapperFactory.builder()
            .withBasePackages(basePackages)
            .withTypeInfoGenerator(infoGen)
            .withFieldNamingStrategy(fieldNamingStrategy)
            .withConfigurer(configurer)
            .build();
}
项目:SteamLib    文件:ReflectiveTypeAdapterFactory.java   
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor,
    FieldNamingStrategy fieldNamingPolicy, Excluder excluder,
    JsonAdapterAnnotationTypeAdapterFactory jsonAdapterFactory) {
  this.constructorConstructor = constructorConstructor;
  this.fieldNamingPolicy = fieldNamingPolicy;
  this.excluder = excluder;
  this.jsonAdapterFactory = jsonAdapterFactory;
}
项目:1797-2017    文件:ReflectiveTypeAdapterFactory.java   
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor,
    FieldNamingStrategy fieldNamingPolicy, Excluder excluder,
    JsonAdapterAnnotationTypeAdapterFactory jsonAdapterFactory) {
  this.constructorConstructor = constructorConstructor;
  this.fieldNamingPolicy = fieldNamingPolicy;
  this.excluder = excluder;
  this.jsonAdapterFactory = jsonAdapterFactory;
}
项目:1797-2017    文件:ReflectiveTypeAdapterFactory.java   
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor,
    FieldNamingStrategy fieldNamingPolicy, Excluder excluder,
    JsonAdapterAnnotationTypeAdapterFactory jsonAdapterFactory) {
  this.constructorConstructor = constructorConstructor;
  this.fieldNamingPolicy = fieldNamingPolicy;
  this.excluder = excluder;
  this.jsonAdapterFactory = jsonAdapterFactory;
}
项目:urmusic-desktop    文件:ReflectiveTypeAdapterFactory.java   
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor,
    FieldNamingStrategy fieldNamingPolicy, Excluder excluder,
    JsonAdapterAnnotationTypeAdapterFactory jsonAdapterFactory) {
  this.constructorConstructor = constructorConstructor;
  this.fieldNamingPolicy = fieldNamingPolicy;
  this.excluder = excluder;
  this.jsonAdapterFactory = jsonAdapterFactory;
}
项目:lastaflute    文件:GsonJsonEngine.java   
protected LaReflectiveTypeAdapterFactory createReflectiveTypeAdapterFactory(Gson newGson, Object factory) {
    final ConstructorConstructor constructorConstructor = getConstructorConstructor(factory);
    final JsonAdapterAnnotationTypeAdapterFactory jsonAdapterFactory = getJsonAdapterFactory(factory);
    final FieldNamingStrategy fieldNamingStrategy = newGson.fieldNamingStrategy();
    final Excluder excluder = newGson.excluder();
    return new LaReflectiveTypeAdapterFactory(constructorConstructor, fieldNamingStrategy, excluder, jsonAdapterFactory);
}
项目:lastaflute    文件:LaReflectiveTypeAdapterFactory.java   
public LaReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor, FieldNamingStrategy fieldNamingPolicy,
        Excluder excluder, JsonAdapterAnnotationTypeAdapterFactory jsonAdapterFactory) {
    this.constructorConstructor = constructorConstructor;
    this.fieldNamingPolicy = fieldNamingPolicy;
    this.excluder = excluder;
    this.jsonAdapterFactory = jsonAdapterFactory;
}
项目:hyperdata    文件:HyperDataGsonBuilder.java   
@Override
protected void doCreate(ConstructorConstructor constructorConstructor, FieldNamingStrategy fieldNamingPolicy, Excluder excluder) {
    registerTypeAdapterFactory(new HyperDataAdapterFactory(constructorConstructor, fieldNamingPolicy, excluder));
    registerTypeAdapter(HyperMap.class, new GsonHyperDataDeserializer());
    registerTypeAdapter(HyperMap.class, new GsonHyperDataSerializer());
    registerTypeAdapter(HyperHashMap.class, new GsonHyperDataDeserializer());
    registerTypeAdapter(HyperHashMap.class, new GsonHyperDataSerializer());
}
项目:letv    文件:ReflectiveTypeAdapterFactory.java   
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor, FieldNamingStrategy fieldNamingPolicy, Excluder excluder) {
    this.constructorConstructor = constructorConstructor;
    this.fieldNamingPolicy = fieldNamingPolicy;
    this.excluder = excluder;
}
项目:odoo-work    文件:ReflectiveTypeAdapterFactory.java   
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor,
    FieldNamingStrategy fieldNamingPolicy, Excluder excluder) {
  this.constructorConstructor = constructorConstructor;
  this.fieldNamingPolicy = fieldNamingPolicy;
  this.excluder = excluder;
}
项目:odoo-work    文件:ReflectiveTypeAdapterFactory.java   
static String getFieldName(FieldNamingStrategy fieldNamingPolicy, Field f) {
  SerializedName serializedName = f.getAnnotation(SerializedName.class);
  return serializedName == null ? fieldNamingPolicy.translateName(f) : serializedName.value();
}
项目:lams    文件:ReflectiveTypeAdapterFactory.java   
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor,
    FieldNamingStrategy fieldNamingPolicy, Excluder excluder) {
  this.constructorConstructor = constructorConstructor;
  this.fieldNamingPolicy = fieldNamingPolicy;
  this.excluder = excluder;
}
项目:boohee_v5.6    文件:ReflectiveTypeAdapterFactory.java   
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor,
                                    FieldNamingStrategy fieldNamingPolicy, Excluder excluder) {
    this.constructorConstructor = constructorConstructor;
    this.fieldNamingPolicy = fieldNamingPolicy;
    this.excluder = excluder;
}
项目:teamcity-build-scan-plugin    文件:SlackPayloadSerializer.java   
private FieldNamingStrategyDelegate(Map<Field, FieldNamingStrategy> customNamings, FieldNamingStrategy delegate) {
    this.customNamings = customNamings;
    this.delegate = delegate;
}
项目:odoo-follow-up    文件:ReflectiveTypeAdapterFactory.java   
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor,
    FieldNamingStrategy fieldNamingPolicy, Excluder excluder) {
  this.constructorConstructor = constructorConstructor;
  this.fieldNamingPolicy = fieldNamingPolicy;
  this.excluder = excluder;
}
项目:odoo-follow-up    文件:ReflectiveTypeAdapterFactory.java   
static String getFieldName(FieldNamingStrategy fieldNamingPolicy, Field f) {
  SerializedName serializedName = f.getAnnotation(SerializedName.class);
  return serializedName == null ? fieldNamingPolicy.translateName(f) : serializedName.value();
}
项目:MyJojoXUtils    文件:ReflectiveTypeAdapterFactory.java   
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor,
    FieldNamingStrategy fieldNamingPolicy, Excluder excluder) {
  this.constructorConstructor = constructorConstructor;
  this.fieldNamingPolicy = fieldNamingPolicy;
  this.excluder = excluder;
}
项目:graphql-spqr    文件:GsonFieldNamingStrategy.java   
public GsonFieldNamingStrategy(FieldNamingStrategy fallback) {
    this.fallback = fallback;
}
项目:graphql-spqr    文件:GsonValueMapperFactory.java   
private GsonValueMapperFactory(String[] basePackages, TypeInfoGenerator typeInfoGenerator, FieldNamingStrategy fieldNamingStrategy, Configurer configurer) {
    this.basePackages = basePackages;
    this.fieldNamingStrategy = Objects.requireNonNull(fieldNamingStrategy);
    this.typeInfoGenerator = Objects.requireNonNull(typeInfoGenerator);
    this.configurer = Objects.requireNonNull(configurer);
}
项目:graphql-spqr    文件:GsonValueMapperFactory.java   
private GsonBuilder initBuilder(FieldNamingStrategy fieldNamingStrategy, Set<Type> abstractTypes, Configurer configurer, GlobalEnvironment environment) {
    GsonBuilder gsonBuilder = new GsonBuilder()
            .setFieldNamingStrategy(fieldNamingStrategy)
            .registerTypeAdapterFactory(new GsonJava8TypeAdapterFactory());
    return configurer.configure(gsonBuilder, abstractTypes, basePackages, this.typeInfoGenerator, environment);
}
项目:graphql-spqr    文件:GsonValueMapperFactory.java   
public Builder withFieldNamingStrategy(FieldNamingStrategy fieldNamingStrategy) {
    this.fieldNamingStrategy = fieldNamingStrategy;
    return this;
}
项目:Camel    文件:GsonDataFormat.java   
public FieldNamingStrategy getFieldNamingStrategy() {
    return fieldNamingStrategy;
}
项目:Camel    文件:GsonDataFormat.java   
public void setFieldNamingStrategy(FieldNamingStrategy fieldNamingStrategy) {
    this.fieldNamingStrategy = fieldNamingStrategy;
}
项目:FMTech    文件:ReflectiveTypeAdapterFactory.java   
public ReflectiveTypeAdapterFactory(ConstructorConstructor paramConstructorConstructor, FieldNamingStrategy paramFieldNamingStrategy, Excluder paramExcluder)
{
  this.constructorConstructor = paramConstructorConstructor;
  this.fieldNamingPolicy = paramFieldNamingStrategy;
  this.excluder = paramExcluder;
}
项目:MiBandDecompiled    文件:ReflectiveTypeAdapterFactory.java   
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorconstructor, FieldNamingStrategy fieldnamingstrategy, Excluder excluder)
{
    a = constructorconstructor;
    b = fieldnamingstrategy;
    c = excluder;
}
项目:android-http-lib-based-on-volley    文件:ReflectiveTypeAdapterFactory.java   
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor,
    FieldNamingStrategy fieldNamingPolicy, Excluder excluder) {
  this.constructorConstructor = constructorConstructor;
  this.fieldNamingPolicy = fieldNamingPolicy;
  this.excluder = excluder;
}
项目:reflect-app    文件:ReflectiveTypeAdapterFactory.java   
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor,
    FieldNamingStrategy fieldNamingPolicy, Excluder excluder) {
  this.constructorConstructor = constructorConstructor;
  this.fieldNamingPolicy = fieldNamingPolicy;
  this.excluder = excluder;
}
项目:ti.box    文件:ReflectiveTypeAdapterFactory.java   
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor,
    FieldNamingStrategy fieldNamingPolicy, Excluder excluder) {
  this.constructorConstructor = constructorConstructor;
  this.fieldNamingPolicy = fieldNamingPolicy;
  this.excluder = excluder;
}
项目:androidsummary    文件:ReflectiveTypeAdapterFactory.java   
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor,
    FieldNamingStrategy fieldNamingPolicy, Excluder excluder) {
  this.constructorConstructor = constructorConstructor;
  this.fieldNamingPolicy = fieldNamingPolicy;
  this.excluder = excluder;
}
项目:Edge-Node    文件:ReflectiveTypeAdapterFactory.java   
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor,
    FieldNamingStrategy fieldNamingPolicy, Excluder excluder) {
  this.constructorConstructor = constructorConstructor;
  this.fieldNamingPolicy = fieldNamingPolicy;
  this.excluder = excluder;
}
项目:BungeeSigns    文件:ReflectiveTypeAdapterFactory.java   
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor,
    FieldNamingStrategy fieldNamingPolicy, Excluder excluder) {
  this.constructorConstructor = constructorConstructor;
  this.fieldNamingPolicy = fieldNamingPolicy;
  this.excluder = excluder;
}
项目:multicraft-api    文件:ReflectiveTypeAdapterFactory.java   
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor,
    FieldNamingStrategy fieldNamingPolicy, Excluder excluder) {
  this.constructorConstructor = constructorConstructor;
  this.fieldNamingPolicy = fieldNamingPolicy;
  this.excluder = excluder;
}
项目:StaticMC    文件:ReflectiveTypeAdapterFactory.java   
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor,
    FieldNamingStrategy fieldNamingPolicy, Excluder excluder) {
  this.constructorConstructor = constructorConstructor;
  this.fieldNamingPolicy = fieldNamingPolicy;
  this.excluder = excluder;
}
项目:hyperdata    文件:HyperDataAdapterFactory.java   
public HyperDataAdapterFactory(ConstructorConstructor constructorConstructor, FieldNamingStrategy fieldNamingPolicy, Excluder excluder) {
    super(constructorConstructor, fieldNamingPolicy, excluder);
    this.constructorConstructor = constructorConstructor;
    this.fieldNamingPolicy = fieldNamingPolicy;
    this.excluder = excluder;
}
项目:gson    文件:ReflectiveTypeAdapterFactory.java   
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor,
    FieldNamingStrategy fieldNamingPolicy, Excluder excluder) {
  this.constructorConstructor = constructorConstructor;
  this.fieldNamingPolicy = fieldNamingPolicy;
  this.excluder = excluder;
}
项目:motech    文件:MotechJsonReader.java   
/**
 * Constructor.
 *
 * @param fieldNamingStrategy  the field naming strategy to be used when deserializing object
 */
public MotechJsonReader(FieldNamingStrategy fieldNamingStrategy) {
    this.fieldNamingStrategy = fieldNamingStrategy;
}