1、取集合中的指定字段为新的集合
List<Long> ids = list.stream().map(CatalogCode::getId).collect(Collectors.toList());
2、根据指定字段排序
List<dto> list = dtoList.stream().sorted(Comparator.comparing(dto::getId)).collect(Collectors.toList());
3、根据条件排序
List<dto> list = form.getList().stream().sorted(Comparator.comparing(dto::getType)).collect(Collectors.toList());
4、将list中的指定字段去重
List<Long> newIds = ids.stream().distinct().collect(toList());
5、根据条件过滤
List<Long> list = ids.stream().filter(item -> otherIds.contains(item)).collect(toList());
List<Long> list = ids.stream().filter(item -> item.getIsTrue == false).collect(toList());
6、统计数量
List<Long> newIds = ids.stream().distinct().collect(toList()).count();
7、根据指定字段分组
Map<String, List<dto>> collect = dtoList.stream().collect(Collectors.groupingBy(dto::getTid));