我的联系方式
邮箱occumacy@163.com
2024-03-26 14:33:47Java
List<QuoteLastAssessmentDetailDTO> lastAssessmentDetails = lastAssessmentDetailAll.stream()
.collect(Collectors.collectingAndThen(Collectors.toCollection(() ->
new TreeSet<>(Comparator.comparing(p -> p.getCustomerId()+";"+p.getOuterMaterialCode()))), ArrayList::new));
Map<Long, List<String>> materialCodeMap = recordDetails.stream()
.collect(Collectors.groupingBy(QuoteRecordDetail::getQuoteCustomId,
Collectors.mapping(QuoteRecordDetail::getOuterMaterialCode, Collectors.toList())));
List<对象>转Map<属性,List<另一个对象>
Map<String, List<PersonDTO>> cityToPersonDTOs = persons.stream()
.collect(Collectors.groupingBy(
Person::getCity,
Collectors.mapping(person -> new PersonDTO(person.getName(), person.getAge()), Collectors.toList())
));