當前位置: 首頁>>代碼示例>>Java>>正文


Java FieldNamingStrategy類代碼示例

本文整理匯總了Java中com.google.gson.FieldNamingStrategy的典型用法代碼示例。如果您正苦於以下問題:Java FieldNamingStrategy類的具體用法?Java FieldNamingStrategy怎麽用?Java FieldNamingStrategy使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FieldNamingStrategy類屬於com.google.gson包,在下文中一共展示了FieldNamingStrategy類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: print

import com.google.gson.FieldNamingStrategy; //導入依賴的package包/類
@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));
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:26,代碼來源:EventsExportEventsToJSON.java

示例2: createEntity

import com.google.gson.FieldNamingStrategy; //導入依賴的package包/類
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);
}
 
開發者ID:eBay,項目名稱:ServiceCOLDCache,代碼行數:16,代碼來源:TrackerClient.java

示例3: create

import com.google.gson.FieldNamingStrategy; //導入依賴的package包/類
@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);
}
 
開發者ID:etiennestuder,項目名稱:teamcity-build-scan-plugin,代碼行數:14,代碼來源:SlackPayloadSerializer.java

示例4: clone

import com.google.gson.FieldNamingStrategy; //導入依賴的package包/類
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();
}
 
開發者ID:leangen,項目名稱:graphql-spqr,代碼行數:12,代碼來源:TestSchemaGenerator.java

示例5: ReflectiveTypeAdapterFactory

import com.google.gson.FieldNamingStrategy; //導入依賴的package包/類
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor,
    FieldNamingStrategy fieldNamingPolicy, Excluder excluder,
    JsonAdapterAnnotationTypeAdapterFactory jsonAdapterFactory) {
  this.constructorConstructor = constructorConstructor;
  this.fieldNamingPolicy = fieldNamingPolicy;
  this.excluder = excluder;
  this.jsonAdapterFactory = jsonAdapterFactory;
}
 
開發者ID:PhilipShilling,項目名稱:SteamLib,代碼行數:9,代碼來源:ReflectiveTypeAdapterFactory.java

示例6: createReflectiveTypeAdapterFactory

import com.google.gson.FieldNamingStrategy; //導入依賴的package包/類
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);
}
 
開發者ID:lastaflute,項目名稱:lastaflute,代碼行數:8,代碼來源:GsonJsonEngine.java

示例7: LaReflectiveTypeAdapterFactory

import com.google.gson.FieldNamingStrategy; //導入依賴的package包/類
public LaReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor, FieldNamingStrategy fieldNamingPolicy,
        Excluder excluder, JsonAdapterAnnotationTypeAdapterFactory jsonAdapterFactory) {
    this.constructorConstructor = constructorConstructor;
    this.fieldNamingPolicy = fieldNamingPolicy;
    this.excluder = excluder;
    this.jsonAdapterFactory = jsonAdapterFactory;
}
 
開發者ID:lastaflute,項目名稱:lastaflute,代碼行數:8,代碼來源:LaReflectiveTypeAdapterFactory.java

示例8: doCreate

import com.google.gson.FieldNamingStrategy; //導入依賴的package包/類
@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());
}
 
開發者ID:filip26,項目名稱:hyperdata,代碼行數:9,代碼來源:HyperDataGsonBuilder.java

示例9: ReflectiveTypeAdapterFactory

import com.google.gson.FieldNamingStrategy; //導入依賴的package包/類
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor, FieldNamingStrategy fieldNamingPolicy, Excluder excluder) {
    this.constructorConstructor = constructorConstructor;
    this.fieldNamingPolicy = fieldNamingPolicy;
    this.excluder = excluder;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:6,代碼來源:ReflectiveTypeAdapterFactory.java

示例10: ReflectiveTypeAdapterFactory

import com.google.gson.FieldNamingStrategy; //導入依賴的package包/類
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor,
    FieldNamingStrategy fieldNamingPolicy, Excluder excluder) {
  this.constructorConstructor = constructorConstructor;
  this.fieldNamingPolicy = fieldNamingPolicy;
  this.excluder = excluder;
}
 
開發者ID:odoo-mobile-intern,項目名稱:odoo-work,代碼行數:7,代碼來源:ReflectiveTypeAdapterFactory.java

示例11: getFieldName

import com.google.gson.FieldNamingStrategy; //導入依賴的package包/類
static String getFieldName(FieldNamingStrategy fieldNamingPolicy, Field f) {
  SerializedName serializedName = f.getAnnotation(SerializedName.class);
  return serializedName == null ? fieldNamingPolicy.translateName(f) : serializedName.value();
}
 
開發者ID:odoo-mobile-intern,項目名稱:odoo-work,代碼行數:5,代碼來源:ReflectiveTypeAdapterFactory.java

示例12: ReflectiveTypeAdapterFactory

import com.google.gson.FieldNamingStrategy; //導入依賴的package包/類
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor,
                                    FieldNamingStrategy fieldNamingPolicy, Excluder excluder) {
    this.constructorConstructor = constructorConstructor;
    this.fieldNamingPolicy = fieldNamingPolicy;
    this.excluder = excluder;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:7,代碼來源:ReflectiveTypeAdapterFactory.java

示例13: FieldNamingStrategyDelegate

import com.google.gson.FieldNamingStrategy; //導入依賴的package包/類
private FieldNamingStrategyDelegate(Map<Field, FieldNamingStrategy> customNamings, FieldNamingStrategy delegate) {
    this.customNamings = customNamings;
    this.delegate = delegate;
}
 
開發者ID:etiennestuder,項目名稱:teamcity-build-scan-plugin,代碼行數:5,代碼來源:SlackPayloadSerializer.java

示例14: GsonFieldNamingStrategy

import com.google.gson.FieldNamingStrategy; //導入依賴的package包/類
public GsonFieldNamingStrategy(FieldNamingStrategy fallback) {
    this.fallback = fallback;
}
 
開發者ID:leangen,項目名稱:graphql-spqr,代碼行數:4,代碼來源:GsonFieldNamingStrategy.java

示例15: GsonValueMapperFactory

import com.google.gson.FieldNamingStrategy; //導入依賴的package包/類
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);
}
 
開發者ID:leangen,項目名稱:graphql-spqr,代碼行數:7,代碼來源:GsonValueMapperFactory.java


注:本文中的com.google.gson.FieldNamingStrategy類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。