title: Java 8 stream and grouping of list
body: <p>I have a list of orders and I want to group them by user using Java 8 <em>stream</em> and <em>Collectors.groupingBy</em>:</p>
  
  <pre><code>orderList.stream().collect(Collectors.groupingBy(order -&gt; order.getUser())
  </code></pre>
  
  <p>This return a map containing users and the list of orders:</p>
  
  <pre><code>Map&lt;User, List&lt;Order&gt;&gt;
  </code></pre>
  
  <p>I don't need the entire object User just a field of it <em>username</em> which is a <em>String</em>, so I want to get something like this:</p>
  
  <pre><code>Map&lt;String, List&lt;Order&gt;&gt;
  </code></pre>
  
  <p>I tried to map the User to the username field using <em>Stream.map</em> but can't get it right. How can I do this as simply as possible? </p>