下面列出了com.google.gson.FieldAttributes#getName ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public boolean shouldSkipField(FieldAttributes f) {
SkipSerialization annotation = f.getAnnotation(SkipSerialization.class);
if (annotation != null)
return true;
String fieldName = f.getName();
Class<?> definedIn = f.getDeclaringClass();
for (Entry<String, Class<?>> include : serializee.getIncludes().entries()) {
if (isCompatiblePath(include, definedIn, fieldName)) {
return false;
}
}
for (Entry<String, Class<?>> exclude : serializee.getExcludes().entries()) {
if (isCompatiblePath(exclude, definedIn, fieldName)) {
return true;
}
}
Field field = reflectionProvider.getField(definedIn, fieldName);
return !serializee.isRecursive() && !shouldSerializeField(field.getType());
}
@Override
public boolean shouldSkipField(FieldAttributes fieldAttributes) {
String fieldName = fieldAttributes.getName();
Class<?> theClass = fieldAttributes.getDeclaringClass();
return isFieldInSuperclass(theClass, fieldName);
}
public boolean shouldSkipField(FieldAttributes fieldAttributes) {
String fieldName = fieldAttributes.getName();
Class<?> theClass = fieldAttributes.getDeclaringClass();
Class<?> superclass = theClass.getSuperclass();
if (this.inheritanceMap.containsKey(theClass)) {
if (getField(this.inheritanceMap.get(theClass), fieldName) != null) {
return true;
}
}
this.inheritanceMap.put(superclass, theClass);
return false;
}
public boolean shouldSkipField(FieldAttributes fieldAttributes) {
String fieldName = fieldAttributes.getName();
Class<?> theClass = fieldAttributes.getDeclaringClass();
return isFieldInSuperclass(theClass, fieldName);
}