title: Java stream group by and sum multiple fields
body: <p>I have a List fooList</p>
  
  <pre><code>class Foo {
      private String category;
      private int amount;
      private int price;
  
      ... constructor, getters &amp; setters
  }
  </code></pre>
  
  <p>I would like to group by category and then sum amount aswell as price.</p>
  
  <p>The result will be stored in a map: </p>
  
  <pre><code>Map&lt;Foo, List&lt;Foo&gt;&gt; map = new HashMap&lt;&gt;();
  </code></pre>
  
  <p>The key is the Foo holding the summarized amount and price, with a list as value for all the objects with the same category.</p>
  
  <p>So far I've tried the following:</p>
  
  <pre><code>Map&lt;String, List&lt;Foo&gt;&gt; map = fooList.stream().collect(groupingBy(Foo::getCategory()));
  </code></pre>
  
  <p>Now I only need to replace the String key with a Foo object holding the summarized amount and price. Here is where I'm stuck. I can't seem to find any way of doing this.</p>