- 过滤、排序
List<Glbdef18VO> glbdef18VOs=Arrays.asList(lrmxVO.getGlbdef18VOs()).stream()
.filter(new Predicate<Glbdef18VO>() {
@Override
public boolean test(Glbdef18VO glbdef18VO) {
if(glbdef18VO.getAttributeValue("glbdef6")==null) {
return false;
}
return ((UFLiteralDate)glbdef18VO.getAttributeValue("glbdef6")).before(endDate);
}})
.sorted(new Comparator<Glbdef18VO>() {
@Override
public int compare(Glbdef18VO o1, Glbdef18VO o2) {
return ((UFLiteralDate)o1.getAttributeValue("glbdef6")).compareTo((UFLiteralDate)o2.getAttributeValue("glbdef6"));
}})
.collect(Collectors.toList());
- 聚合
Optional<Glbdef18VO> mergedGlbdef18VO=entry.getValue().stream().reduce(new BinaryOperator<Glbdef18VO>() {
@Override
public Glbdef18VO apply(Glbdef18VO o1, Glbdef18VO o2) {
o1.setAttributeValue("glbdef10", o1.getAttributeValue("glbdef10")+";"+o2.getAttributeValue("glbdef10"));
return o1;
}
});
if(mergedGlbdef18VO.isPresent()) {
mergedGlbdef18VOs.add(mergedGlbdef18VO.get());
}
- 分组
Map<String,List<ScoreDetaillVO>> raterScoreDetaillVOMap=Stream.generate(scoreDetaillVOs.iterator()::next)
.limit(scoreDetaillVOs.size())
.collect(Collectors.groupingBy(ScoreDetaillVO::getRater));
- List转Map
Map<String, FillDataDetailVO> rootScoreDetailVOs = Arrays.asList(scoreDetailVOs).stream()
.filter(new Predicate<FillDataDetailVO>() {
@Override
public boolean test(FillDataDetailVO scoreDetaillVO) {
return scoreDetaillVO.getIndicatorspid() == null;
}
}).collect(Collectors.toMap(FillDataDetailVO::getIndicators, o -> o));