kdlug
4/28/2020 - 9:33 AM

Stream

// check if values are null  
            if (Stream.of(summary.getBaseGrandTotal(),summary.getGrandTotal(),
                    summary.getBasePaymentCharge(),summary.getPaymentCharge()).anyMatch(Objects::isNull)) {
                throw new Exception("Summary data is missing.");
            }
            
// stream to map     
Map<String, List<String>> aggregatedOrderItems = orderItems.stream()
.collect(Collectors.groupingBy(OrderItem::getOfferId, Collectors.mapping(OrderItem::getId, Collectors.toList())));