> 根据实体类的某个字段去重
userList.stream().collect(Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(User::getUsername))), ArrayList::new
));
>?list 转 map
Map<Long, String> userMap = userList.stream().collect(
Collectors.toMap(UserListDto::getId, UserListDto::getName)
);
Map<String, List<OrgImport>> groupByOrgCode = data.stream().collect(
Collectors.groupingBy(OrgImport::getOrgCode)
);
Map<String, ContractVo> collect = contractList.stream().collect(
Collectors.toMap(ContractVo::getSymbol, paperContractVo -> ContractVo)
);
> 根据实体类的某个字段求和
BigDecimal total = computeList.stream()
.map(parcel -> parcel.getNumBbl())
.reduce(BigDecimal.ZERO, BigDecimal::add);