title: Create map from Java stream?
body: <p>I am trying to create a <code>map</code> from a <code>Java</code> <code>stream</code>.  I am able to do this easily with <code>javascript</code> and am trying to create the same thing in <code>Java</code>.  Here is my data structure:</p>
  
  <pre><code>var slips = [
    {
      original: 'Y',
      lines: [
        {
          detailLines: {
            detailLineId: 111
          }
        },
        {
          detailLines: {
            detailLineId: 222
          }
        }
      ]
    },
    {
      original: 'N',
      lines: [
        {
          detailLines: {
            detailLineId: 333
          }
        },
        {
          detailLines: {
            detailLineId: 444
          }
        }
      ]
    }
  ]
  </code></pre>
  
  <p>Here is how I did it in <code>javascript</code></p>
  
  <pre><code>var test = slips.reduce((acc, slip) =&gt; {
    slip.lines.map(line =&gt; line.detailLines.detailLineId)
              .map(arr =&gt; acc[arr] = slip.original);
    return acc;
  }, {});
  </code></pre>
  
  <p>to get my result of </p>
  
  <pre><code>{ 
    '111': 'Y', 
    '222': 'Y', 
    '333': 'N', 
    '444': 'N' 
  }
  </code></pre>
  
  <p>How do I do this using the Java 8 Stream api?  The <code>slips</code> above really is just a <code>POJO</code>.  I converted it to a <code>JSON</code> object to do figure it out in <code>js</code>.  The real structure of the Objects are</p>
  
  <pre><code>class Slip {
    private Boolean original;
    private List&lt;Line&gt; lines;
  }
  
  class Line {
    private List&lt;DetailLine&gt; detailLines;
  }
  
  class DetailLine {
    private Long detailLine;
  }
  </code></pre>
  
  <p>So what I have started with the <code>Java</code> is </p>
  
  <pre><code>Map&lt;Long, Boolean&gt; results = slips.stream().reduce(new Map&lt;Long, Boolean&gt;, ...)
  </code></pre>