java.lang.NullPointerException:

2020-08-17  本文已影响0人  星空中的浮云

这行代码 getSupplierLoginId 可为空时会报这种错误

Map<String, List<PurchaseOrderEntity>> collect = purchaseOrderEntities.stream().collect(Collectors.groupingBy(PurchaseOrderEntity::getSupplierLoginId));

代码修改后对空值进行过滤:

Map<String, List<PurchaseOrderEntity>> collect = purchaseOrderEntities.stream().filter(item-> StringUtil.isNotBlank(item.getSupplierLoginId())).collect(Collectors.groupingBy(PurchaseOrderEntity::getSupplierLoginId));

上一篇下一篇

猜你喜欢

热点阅读