本文整理汇总了Java中com.google.gson.annotations.SerializedName.value方法的典型用法代码示例。如果您正苦于以下问题:Java SerializedName.value方法的具体用法?Java SerializedName.value怎么用?Java SerializedName.value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gson.annotations.SerializedName
的用法示例。
在下文中一共展示了SerializedName.value方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: EnumTypeAdapter
import com.google.gson.annotations.SerializedName; //导入方法依赖的package包/类
public EnumTypeAdapter(Class<T> classOfT) {
try {
for (T constant : (Enum[]) classOfT.getEnumConstants()) {
String name = constant.name();
SerializedName annotation = (SerializedName) classOfT.getField(name)
.getAnnotation(SerializedName.class);
if (annotation != null) {
name = annotation.value();
}
this.nameToConstant.put(name, constant);
this.constantToName.put(constant, name);
}
} catch (NoSuchFieldException e) {
throw new AssertionError();
}
}
示例2: serializedName
import com.google.gson.annotations.SerializedName; //导入方法依赖的package包/类
private static String serializedName(Member member) {
if(member instanceof AnnotatedElement) {
SerializedName nameAnnot = ((AnnotatedElement) member).getAnnotation(SerializedName.class);
if(nameAnnot != null) return nameAnnot.value();
}
return member.getName();
}
示例3: getName
import com.google.gson.annotations.SerializedName; //导入方法依赖的package包/类
private String getName(Field field){
SerializedName anotation = field.getAnnotation(SerializedName.class);
if(anotation == null){
return field.getName();
}
return anotation.value();
}
示例4: EnumTypeAdapter
import com.google.gson.annotations.SerializedName; //导入方法依赖的package包/类
public EnumTypeAdapter(Class<T> classOfT) {
try {
for (T constant : (Enum[]) classOfT.getEnumConstants()) {
String name = constant.name();
SerializedName annotation = (SerializedName) classOfT.getField(name).getAnnotation(SerializedName.class);
if (annotation != null) {
name = annotation.value();
}
this.nameToConstant.put(name, constant);
this.constantToName.put(constant, name);
}
} catch (NoSuchFieldException e) {
throw new AssertionError();
}
}
示例5: EnumTypeAdapter
import com.google.gson.annotations.SerializedName; //导入方法依赖的package包/类
public EnumTypeAdapter(Class<T> classOfT) {
try {
for (T constant : classOfT.getEnumConstants()) {
String name = constant.name();
SerializedName annotation = classOfT.getField(name).getAnnotation(SerializedName.class);
if (annotation != null) {
name = annotation.value();
}
nameToConstant.put(name, constant);
constantToName.put(constant, name);
}
} catch (NoSuchFieldException e) {
throw new AssertionError();
}
}
示例6: getFieldName
import com.google.gson.annotations.SerializedName; //导入方法依赖的package包/类
private String getFieldName(Field f) {
SerializedName serializedName = (SerializedName) f.getAnnotation(SerializedName.class);
return serializedName == null ? this.fieldNamingPolicy.translateName(f) : serializedName.value();
}
示例7: getFieldName
import com.google.gson.annotations.SerializedName; //导入方法依赖的package包/类
static String getFieldName(FieldNamingStrategy fieldNamingPolicy, Field f) {
SerializedName serializedName = f.getAnnotation(SerializedName.class);
return serializedName == null ? fieldNamingPolicy.translateName(f) : serializedName.value();
}
示例8: getFieldName
import com.google.gson.annotations.SerializedName; //导入方法依赖的package包/类
private String getFieldName(Field f) {
SerializedName serializedName = f.getAnnotation(SerializedName.class);
return serializedName == null ? fieldNamingPolicy.translateName(f) : serializedName.value();
}
示例9: serialize
import com.google.gson.annotations.SerializedName; //导入方法依赖的package包/类
@Override public JsonElement serialize(T src, Type typeOfSrc, JsonSerializationContext context) {
if (src == null) return JsonNull.INSTANCE;
SerializedName annotation = getSerializedName(src);
return new JsonPrimitive(annotation == null ? src.name() : annotation.value());
}
示例10: getFieldName
import com.google.gson.annotations.SerializedName; //导入方法依赖的package包/类
private String getFieldName(Field f) {
SerializedName serializedName = (SerializedName) f.getAnnotation(SerializedName.class);
return serializedName == null ? this.fieldNamingPolicy.translateName(f) : serializedName
.value();
}