- 逗号拼接list中的某一对象字段
millAndKilns.stream().map(MillAndKiln::getName).collect(Collectors.joining(","));
- 将对象集合中的某一个字段提取成一个新的集合
List<Long> appUnitIds = appUnitVOPage.getRecords().stream().map(AppUnitListVO::getId).collect(Collectors.toList());
- 根据id分组成key-value形式
Map<Long, List<AppField>> appFieldMap = fields.stream().collect(Collectors.groupingBy(AppField::getAppId));
- 判断集合中莫格对象字段是否包含指定值
versions.stream().map(AppVersion::getIsShelf).collect(Collectors.toList()).contains(PlatformConstant.IsShelf.ON_THE_SHELF)
- 集合根据莫格字段排序
versions.stream().sorted(Comparator.comparing(AppVersion::getUpdateTime).reversed()).collect(Collectors.toList())
- list集合根据某个字段进行过滤
List<AppVersion> appVersionS = versions.stream().filter(AppVersion -> PlatformConstant.IsShelf.ON_THE_SHELF.equals(AppVersion.getIsShelf())).collect(Collectors.toList());
- list根据对象的某个字段给对象去重
List<CustomerSaleRelation> customerDeduplication = relations.stream().collect(
Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(CustomerSaleRelation::getCustomerId))), ArrayList::new));