日期:2014-05-16 浏览次数:20440 次
/** 用于 goods 的 json config */
public static JsonConfig jsonConfig = new JsonConfig();
static {
jsonConfig.setJsonPropertyFilter(new PropertyFilter() {
public boolean apply(Object source, String name, Object value) {
if (source.getClass() == Goods.class) { // 过滤掉 Goods 中的 GoodsType
Field declaredField = null;
try {
declaredField = source.getClass().getDeclaredField(name);
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
if (declaredField.getType() == GoodsType.class) {
return true;
} else {
return false;
}
} else {
return false;
}
}
});
}