自我学习记录
多条件过滤
baseInfo是list列表,根据enterpriseId,attrId,month过滤数据
baseInfo.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(
() -> new TreeSet<>(Comparator.comparing(BasicIndicatorData::getEnterpriseId)
.thenComparing(BasicIndicatorData::getAttrId)
.thenComparing(BasicIndicatorData::getMonth))
), ArrayList::new));
stream().map 中的自增变量
AtomicInteger sort = new AtomicInteger(1);
list.stream().map(info ->
{
info.setAge("111");
info.setSort(sort.getAndIncrement());
return info;
}
).collect(Collectors.toList());