美文网首页
java.lang.NullPointerException:

java.lang.NullPointerException:

作者: 星空中的浮云 | 来源:发表于2020-08-17 18:04 被阅读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));

    相关文章

      网友评论

          本文标题:java.lang.NullPointerException:

          本文链接:https://www.haomeiwen.com/subject/pxcsjqtx.html