使用CollectionUtils的Predicate来过滤一个集合list中某种class的子集合
CollectionUtils.filter(this.list, new Predicate(){
public boolean evaluate(Object object) {
if(object instanceof TSysDepartment){//TSysDepartment为要过滤的对象
return false;
}
return true;
}
});
本文介绍如何使用CollectionUtils的filter方法配合自定义Predicate条件,从集合中排除特定类的实例。示例代码展示了如何排除TSysDepartment类的实例。
使用CollectionUtils的Predicate来过滤一个集合list中某种class的子集合
CollectionUtils.filter(this.list, new Predicate(){
public boolean evaluate(Object object) {
if(object instanceof TSysDepartment){//TSysDepartment为要过滤的对象
return false;
}
return true;
}
});

被折叠的 条评论
为什么被折叠?