您的位置:首页 > 其它

list集合根据对象属性去重以及根据对象某个属性逆序排序,相同则使用另一个进行排序

2019-03-25 14:40 555 查看

去重:

couponInfos.addAll(couponInfoList);
couponInfos = couponInfos.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(CouponInfo::getCouponInfoId))), ArrayList::new));

排序:

couponInfos.sort(Comparator.comparing(CouponInfo::getCreateTime).reversed().thenComparing(CouponInfo::getIsExpire));
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: