title: Java 8 convert Map<Department, List<Person>> to Map<Department, List<String>>
body: <p>Using <code>Collectors.groupingBy()</code> I can easily obtain a <code>Map&lt;Department, List&lt;Person&gt;&gt;</code> - this gives me all the <code>Person</code> objects that are part of a <code>Department</code>:</p>
  
  <pre><code>allPersons.stream().collect(Collectors.groupingBy(Person::getDepartment));
  </code></pre>
  
  <p>Now I would like to convert the resulting 'multimap' so that it contains all Persons' names and not the <code>Person</code> objects.</p>
  
  <p>One way to achieve this is:</p>
  
  <pre><code>final Map&lt;Department, List&lt;String&gt;&gt; newMap = new HashMap&lt;&gt;();
  personsByDepartmentMap.stream
      .forEach((d, lp) -&gt; newMap.put(
           d, lp.stream().map(Person::getName).collect(Collectors.toList())));
  </code></pre>
  
  <p>Is there a way to achieve this without using the <code>newMap</code> object?
  Something like</p>
  
  <pre><code>final Map&lt;Department, List&lt;String&gt;&gt; newMap = 
                  personsByDepartmentMap.stream().someBigMagic();
  </code></pre>