//list转对象map
Map<String, SSubject> subject =subjectList.stream().collect(Collectors.toMap(SSubject::getSubjectName, item -> item, (item1, item2) -> item1));
//list分组
Map<Integer, List<CCertificateAnswer>> answerMap = answerList.stream().collect(Collectors.groupingBy(CCertificateAnswer::getCertificateDetailId));
//filter
if (StringUtils.isNotEmpty(accountsReceivableDTO.getInvoiceNo())) {
accountsReceivableVOList = accountsReceivableVOList.stream().filter(accountsReceivableVO ->
(StringUtils.isNotEmpty(accountsReceivableVO.getInvoiceNo())) && accountsReceivableVO.getInvoiceNo().contains(accountsReceivableDTO.getInvoiceNo())).collect(Collectors.toList());
}
//求和
BigDecimal debitBalance = collect2.stream().map(v -> Optional.ofNullable(v.getDebitAmount()).orElse(BigDecimal.ZERO)).reduce(BigDecimal.ZERO, BigDecimal::add);
Set newList = objectList.stream().map(Object::getVar).collect(Collectors.toSet());
cat byt-finance-byt.log | grep 操作异常
list.stream().collect(Collectors.toMap(集合中类::集合中类属性, 集合中类::集合中类属性, (k1, k2) -> k2, LinkedHashMap::new));
1.8stream
最新推荐文章于 2024-11-03 11:01:20 发布