in gson/src/java/org/apache/fulcrum/json/gson/GSONBuilderService.java [393:436]
private ExclusionStrategy include(Class clazz, String... filterAttrs) {
return new ExclusionStrategy() {
private Class<?> includeThisClass;
private HashSet<String> includedAttributes;
private ExclusionStrategy init(Class<?> includeThisClass,
String... filterAttrs) {
this.includeThisClass = includeThisClass;
if (filterAttrs != null) {
this.includedAttributes = new HashSet<String>(
filterAttrs.length);
getLogger().debug(" ... adding includedAttributes:" + filterAttrs.length);
Collections.addAll(this.includedAttributes, filterAttrs);
for (String includedAttribute : includedAttributes) {
getLogger().debug("includedAttribute:" +includedAttribute);
}
} else
this.includedAttributes = new HashSet<String>();
return this;
}
/**
* skip is current class is not equal provided class
*/
@Override
public boolean shouldSkipClass(Class<?> clazz) {
getLogger().debug(includeThisClass+ ": comparing include class:" + clazz);
return includeThisClass != null ? !includeThisClass
.equals(clazz) : false;
}
/**
* skip if current field attribute is not included are skip else
*/
@Override
public boolean shouldSkipField(FieldAttributes paramFieldAttributes) {
return !includedAttributes.isEmpty() ? !this.includedAttributes
.contains(paramFieldAttributes.getName()) : true;
}
}.init(clazz, filterAttrs);
}