lambda表达式(持续更新中)

List<MatchItem> matches = getList(itemCode);
//根据内容去重
itemList = itemList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(()->
new TreeSet<>(Comparator.comparing(MatchItem::getContent))), ArrayList::new));

//合并list中的信息变成字符串(无分隔符)
String wholeValue = itemList.stream().filter(item-> StringUtils.isNotBlank(item.getContent()))
.map(MatchItem :: getContent).collect(Collectors.joining());
//降序排列
matches.sort((a,b) -> Float.compare(b.getY(),a.getY()));
//升序
matches.sort((a,b) -> Float.compare(a.getY(),b.getY()));
//过滤list
matches = matches.stream().filter(item->!"空字符串".equals(item.getContent().trim())).collect(Collectors.toList());
/** 按照***相等分组*/
Map<Float, List<MatchItem>> groupBy = matches.stream().collect(Collectors.groupingBy(MatchItem::getY));
posted @ 2021-12-23 11:15  悄悄地超越  阅读(24)  评论(0编辑  收藏  举报