可以使用Optional的map方法来简化代码:

List orderList = customerProductOrderInfoService.selectByCreditId(item.getId()); // 订单为一条时列表展示订单状态 if (orderList.size() == 1) { item.setOrderStatus(orderList.stream() .map(x -> OrderStatus.getDescByCode(x.getOrderStatus())) .filter(Optional::isPresent) .map(Optional::get) .findFirst() .orElse(null)); }

ListCustomerProductOrderInfo orderList = customerProductOrderInfoServiceselectByCreditIditemgetId; 订单为一条时列表展示订单状态 if orderListsize == 1 orderListstreamfindAny

原文地址: https://www.cveoy.top/t/topic/gASg 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录