title: Mapping a list to Map Java 8 stream and groupingBy
body: <p>I have this simple Bean class:</p>
  
  <pre><code>public class Book {     
  
  public Book(Map&lt;String, String&gt; attribute) {
      super();
      this.attribute = attribute;
  }
  //key is isbn, val is author
  private Map&lt;String, String&gt; attribute;
  
  public Map&lt;String, String&gt; getAttribute() {
      return attribute;
  }
  public void setAttribute(Map&lt;String, String&gt; attribute) {
      this.attribute = attribute;
  }
  
  }
  </code></pre>
  
  <p>In my main class, I have added some information to the List:</p>
  
  <pre><code>    Map&lt;String, String&gt; book1Details = new HashMap&lt;String, String&gt;();
      book1Details.put("1234", "author1");
      book1Details.put("5678", "author2");
      Book book1 = new Book(book1Details);
  
      Map&lt;String, String&gt; book2Details = new HashMap&lt;String, String&gt;();
      book2Details.put("1234", "author2");
      Book book2 = new Book(book2Details);
  
      List&lt;Book&gt; books = new ArrayList&lt;Book&gt;();
      books.add(book1);
      books.add(book2);
  </code></pre>
  
  <p>Now I want to convert the books List to a map of this form:</p>
  
  <pre><code>Map&lt;String, List&lt;String&gt;&gt;
  </code></pre>
  
  <p>So that the output (the map above) is like:</p>
  
  <pre><code>//isbn: value1, value2
  1234: author1, author2
  5678: author1
  </code></pre>
  
  <p>So, I need to group the entries by isbn as key and authors as values. One isbn can have multiple authors.</p>
  
  <p>I am trying like below:</p>
  
  <pre><code>Map&lt;String, List&lt;String&gt;&gt; library = books.stream().collect(Collectors.groupingBy(Book::getAttribute));
  </code></pre>
  
  <p>The format of the bean cannot be changed. If the bean had string values instead of map, I am able to do it, but stuck with the map.</p>
  
  <p>I have written the traditional java 6/7 way of doing it correctly, but trying to do it via Java 8 new features. Appreciate the help.</p>