If I have a list of object say products, that are to be grouped by product type. And I need the aggregated price and quantity.
{{name:a1,type:normal,price:23,quantity:4},
{name:a2,type:normal,price:3,quantity:3},
{name:a3,type:luxury,price:233,quantity:1},
{name:a4,type:luxury,price:123,quantity:2}}
I need a resultant list which looks like this
{{type:normal,price:26,quantity:7},{type:luxury,price:356,quantity:3}}
Is there a way to achieve this using java streams??