一: filter过滤
bill.setSettlement(settlements.stream().filter(e -> {
PexSettlement settlement = settlementMap.get(bill.getContentBill().getBillId());
if(Objects.isNull(settlement)){
return false;
}else
return settlement.getSettlementType().equalsIgnoreCase((String) e.get("code")) ? true : false;
}).collect(Collectors.toList()));
listAssignee= listAssigneeAll.stream().filter(ele->!ele.getAssignee().equals(bill.getCreator())).collect(Collectors.toList());
二:map的用法
if(!ObjectUtils.isEmpty(gcuJournals)) {
summarys = gcuJournals.stream().map(GcuJournal::getSummary).filter(value ->StringUtils.isNotEmpty(value)).distinct().collect(Collectors.toList());
}
People ss=new People();
ss.setAge("18");
ss.setName("小明");
ss.setSex("男");
People aa=new People();
aa.setAge("19");
aa.setName("小李");
aa.setSex("女");
List<People> list =new ArrayList<People>();
list.add(ss);
list.add(aa);
list.add(dd);
//List<String> newLsit=list.stream().map(People::getName).filter(ee->!StringUtil.isNullOrEmpty(ee)).distinct().collect(Collectors.toList());
List<String> newLsit=list.stream().map(People::getName).collect(Collectors.toList());
for (String string : newLsit) {
System.out.println(string);
}