在java中有这么段代码, notifyInfoCCDetail.stream() .map(passengerDetailInfo -> new PassengerDetailInfoPhoneNbr( passengerDetailInfo.getPassengerPhoneNbr(), passengerDetailInfo.getEcifPhoneNbr(), passengerDetailInfo.getAgentPhoneNbr(), passengerDetailInfo.getCustomPhoneNbr(), passengerDetailInfo.getChnName(), passengerDetailInfo.getOldFltDt(), passengerDetailInfo.getOldDptAirportCd(), passengerDetailInfo.getOldArvAirportCd(), passengerDetailInfo.getOldFltNbr(), passengerDetailInfo.getNewFltDt(), passengerDetailInfo.getNewDptAirportCd(), passengerDetailInfo.getNewArvAirportCd(), passengerDetailInfo.getNewFltNbr() )) .distinct() // 使用forEach()方法将转换后的对象添加到 List<PassengerDetailInfoPhoneNbr> phoneList中。 .forEach(phoneList::add);根据passengerPhoneNbr,ecifPhoneNbr,agentPhoneNbr,customPhoneNbr,chnName去重,将完整代码展示出来
时间: 2024-02-10 14:14:35 浏览: 44
FSO生成UTF-8编码文件的解决方法
5星 · 资源好评率100%
这段代码是将 `notifyInfoCCDetail` 集合中的元素转换为 `PassengerDetailInfoPhoneNbr` 对象,并将其添加到 `phoneList` 集合中。在转换的过程中,使用 `distinct()` 方法去除重复的元素。完整代码如下:
```
List<PassengerDetailInfoPhoneNbr> phoneList = new ArrayList<>();
notifyInfoCCDetail.stream()
.map(passengerDetailInfo -> new PassengerDetailInfoPhoneNbr(
passengerDetailInfo.getPassengerPhoneNbr(),
passengerDetailInfo.getEcifPhoneNbr(),
passengerDetailInfo.getAgentPhoneNbr(),
passengerDetailInfo.getCustomPhoneNbr(),
passengerDetailInfo.getChnName(),
passengerDetailInfo.getOldFltDt(),
passengerDetailInfo.getOldDptAirportCd(),
passengerDetailInfo.getOldArvAirportCd(),
passengerDetailInfo.getOldFltNbr(),
passengerDetailInfo.getNewFltDt(),
passengerDetailInfo.getNewDptAirportCd(),
passengerDetailInfo.getNewArvAirportCd(),
passengerDetailInfo.getNewFltNbr()
))
.distinct()
.forEach(phoneList::add);
```
阅读全文