title: Java 8 streams: iterate over Map of Lists
body: <p>I have the following Object and a Map:</p>
  
  <pre><code>MyObject
      String name;
      Long priority;
      foo bar;
  
  Map&lt;String, List&lt;MyObject&gt;&gt; anotherHashMap;
  </code></pre>
  
  <p>I want to convert the Map in another Map. The Key of the result map is the key of the input map. The value of the result map ist the Property "name" of My object, ordered by priority.</p>
  
  <p>The <em>ordering</em> and extracting the name is not the problem, but I could not put it into the result map. I do it the old Java 7 way, but it would be nice it is possible to use the streaming API.</p>
  
  <pre><code>Map&lt;String, List&lt;String&gt;&gt; result = new HashMap&lt;&gt;();
  for (String identifier : anotherHashMap.keySet()) {
      List&lt;String&gt; generatedList = anotherHashMap.get(identifier).stream()...;
  
      teaserPerPage.put(identifier, generatedList);
  }
  </code></pre>
  
  <p>Has anyone an idea? I tried this, but got stuck:</p>
  
  <pre><code>anotherHashMap.entrySet().stream().collect(Collectors.asMap(..., ...));
  </code></pre>