首页 > 技术文章 > java 根据条件从List中筛选出符合条件的集合

zhangxuetao 2020-06-03 09:08 原文

    public Collection checkList(List list, String tableColumnName, String agers){
        List templist = new ArrayList();
        EqualPredicate parameter = new EqualPredicate(agers);
        BeanPredicate tableCoulmn_paramerter = new BeanPredicate(tableColumnName, parameter);
        Predicate[] allPredicateArray = {tableCoulmn_paramerter };
        Predicate allPredicate = PredicateUtils.allPredicate(allPredicateArray);
        Collection<MkArea> filteredCollection = org.apache.commons.collections.CollectionUtils.select(list, allPredicate);
        return filteredCollection;
    }
import org.apache.commons.collections.PredicateUtils;
import org.apache.commons.collections.functors.EqualPredicate;
import org.apache.commons.collections.Predicate;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Transformer;
import java.util.Collection;
import org.apache.commons.beanutils.BeanPredicate;

 

推荐阅读