anyMatch表示,判断的条件里,任意一个元素成功,返回true
allMatch表示,判断条件里的元素,所有的都是,返回true
noneMatch跟allMatch相反,判断条件里的元素,所有的都不是,返回true
//将list用or连接拼成字符串
String join = Joiner.on(" OR ").join(xkBhList);
String join = String.join("," , xkList);
//Collections.disjoint()查询两个list中不存在公共元素时返回true,否则返回false
boolean doNotRepeat=Collections.disjoint(Arrays.asList(x.getSubjectCode().split(",")),subjectCodeList)
求list中某字段的和:
List<Statistics> statistics = statisticsDao.listStatisticsVo(queryStatisticsParam);
Stream<Statistics> statisticsVoStream = statistics.stream().filter(y -> x.getYxBh().equals(y.getYxBh()));
double statisticsValue = statisticsVoStream.mapToDouble(x -> Double.parseDouble(x.getGcdSz())).sum();
依据某个字段筛选:
Stream<Statistics> statisticsVoStream = statistics.stream().filter(x -> schoolCode.equals(x.getXxBh()));
依据某个字段筛选并返回map集合:
Map tempSubjectGroupMap=xkList.stream().filter(s -> paramList.contains(s.getXkBh())).collect(Collectors.toMap(Xk::getXkBh, Xk::getXkMc));
一个集合list依据某字段去重:
List<ExpertInfo> list = allList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(ExpertInfo :: getId))), ArrayList::new));
依据某字段排序,返回List
List<StatisticsNodeOrderVo> statisticsOrder = new ArrayList<>();
List<StatisticsNodeOrderVo> orderList orderList = statisticsOrder.stream().sorted(Comparator.comparing(StatisticsNodeOrderVo::getValueStr, Comparator.comparingDouble(Double::parseDouble))).collect(Collectors.toList());
List<StatisticsNodeOrderVo> orderList orderList = statisticsOrder.stream().sorted(Comparator.comparing(StatisticsNodeOrderVo::getValueStr, Comparator.comparingDouble(Double::parseDouble).reversed())).collect(Collectors.toList());
Collections.emptyList(); //返回一个空List