I have a list of LineItem.What i want is filter the list by the lineItemId and get the sum of quantity of the filtered element and filtered list both.
public class LineItem {
private Item item;
private int quantity;
private String lineItemId;
}
I wrote the code like this
purchases.stream()
.map(purchaseItem -> identifyAndGetLineItem(purchaseItem,awardPointsForSaleRequest.getLineItems()))
.filter(lineItem -> lineItem.getQuantity() > 0)
.collect(Collectors.toMap())
Basically,What i want a Map,one key will contain the value of the filtered list and another will contain the sum of the quantity of the filtered list