org.apache.commons.collections.CollectionUtils高效遍历的使用
2017-11-27 16:03
393 查看
api地址:http://commons.apache.org/proper/commons-collections/javadocs/api-3.2.2/index.html
org.apache.commons.collections.CollectionUtils:
1.static Collection select(Collection inputCollection, Predicate predicate):可以根据集合对象中的属性进行判断,return符合条件的新对象,并组成集合返回,用法同2
2.static void forAllDo(Collection collection, Closure closure):可以修改集合里的对象的属性
例子:
org.apache.commons.collections.CollectionUtils:
1.static Collection select(Collection inputCollection, Predicate predicate):可以根据集合对象中的属性进行判断,return符合条件的新对象,并组成集合返回,用法同2
2.static void forAllDo(Collection collection, Closure closure):可以修改集合里的对象的属性
例子:
List<ActivityWinRecord> activityWinRecords = activityWinRecordMapper.selectListPartByExample(example, pageVo); //如果是实物奖品,并且已经到了过期时间,修改状态为已过期 CollectionUtils.forAllDo(activityWinRecords, new Closure() { @Override public void execute(Object input) { ActivityWinRecord activityWinRecord = (ActivityWinRecord)input; Date expriedDate = activityWinRecord.getExpiredDate(); if(PrizeEnums.MATERIAL.getName().equals(activityWinRecord.getPrizeType())&&expriedDate!=null){ if(new Date().getTime()>=expriedDate.getTime()){ activityWinRecord.setStatus(ReceiveStatusEnums.EXPIRED.getName()); } } } });
相关文章推荐
- 使用org.apache.commons.collections.CollectionUtils进行List与List比较
- apache commons collections CollectionUtils工具类简单使用
- org.apache.commons.collections.CollectionUtils
- apache commons collections CollectionUtils工具类简单使用
- apache commons collections CollectionUtils工具类简单使用
- org.apache.commons.collections.CollectionUtils
- NoSuchMethodError: org.apache.commons.collections.CollectionUtils.isNotEmpty(Ljava/util/Collection;)
- apache commons collections CollectionUtils工具类简单使用
- apache commons collections CollectionUtils工具类简单使用
- 集合工具类 org.apache.commons.collections.CollectionUtils
- apache commons collections CollectionUtils工具类简单使用
- org.apache.commons.collections.CollectionUtils
- org.apache.commons.collections.CollectionUtils
- org.apache.commons.collections.CollectionUtils
- apache commons collections CollectionUtils工具类简单使用
- apache commons collections CollectionUtils工具类简单使用
- org.apache.commons.lang.xwork.StringUtils 问题的解决!json使用时产生的问题
- 日期工具类org.apache.commons.lang.time.DateUtils,使用公共类
- 使用org.apache.commons.lang.StringUtils方法containsAny误区 看看你们遇到过没有
- org.apache.commons.lang.StringUtils 工具类的使用