title: Is this the right use of java.util.stream?
body: <h1>Update</h1>
  <p>Ok, I think I know how to work with streams now. The code in the old post is a mess and I'm not proud of it. So, thank you for you help for directing me in the right direction. I wrote a <em>supplier class</em>, which provides me with items and used static <em>filters</em> and <em>mapper</em> functions:</p>
  <pre><code>final TradeSupplier tradeSupplier = new TradeSupplier();
  Stream.generate(tradeSupplier).map(TradeSupplier::getPrice)
          .map(TradeSupplier::getTradePartner)
          .map(TradeSupplier::getTradeInfo)
          .filter(TradeSupplier::validateInfo)
          .map(TradeSupplier::getPartnerAssetId)
          .filter(TradeSupplier::validatePartnerAssetId).forEach(t -&gt; {
              if (trade.sendTrade(t)) {
                  tradeSupplier.finishedItem();
                  TradeCache.save(t);
              }
          });
  </code></pre>
  <p>With this design, I don't need <code>flatMap</code>, because it's just an one by one mapping. Additional information is filed into the item, which is just in the stream
  I hope, this code is better than the code below... What do you think?
  I'm appreciative for any help to improve my understanding of streams :)</p>
  <hr />
  <h1>Old post</h1>
  <p>I'm looking for help for the &quot;new&quot; stream api of java 8: first I get a list of items, for every item I collect a list of strings and after that, i want to combine the string with their corresponding item:</p>
  <h3>input:</h3>
  <ul>
  <li>item1</li>
  <li>item2</li>
  </ul>
  <h3>wanted output:</h3>
  <ul>
  <li>item1; string1</li>
  <li>item1; string2</li>
  <li>item2; string1</li>
  <li>item2; string2</li>
  <li>item2; string3</li>
  </ul>
  <p>Is the following code the right way to use this api?</p>
  <h3>Code (with stream api)</h3>
  <pre><code>// input is a list of items
  analyst.getInRange(wantMinValue, wantMaxValue)
          .stream()
          .filter(i -&gt; !haveItem.getName().contains(i.getName())
                  || (!haveItem.getModel().contains(i.getModel()) &amp;&amp; haveItem
                          .getQuality() &gt; i.getQuality()))
  // get extra information and add it to a list (key: item; value: string) 
          .collect(Collectors.toMap(s -&gt; s, s -&gt; lounge.getItemId(s)))
          .entrySet()
          .stream()
  // delete all null and empty strings 
          .filter(e -&gt; e.getValue() != null &amp;&amp; !e.getValue().isEmpty())
  // for every entry in list, create an list and add to result
          .forEach(
                  e -&gt; {
                      lounge.getListOfValue(e.getValue(), 1)
                              .stream()
                              .filter(s -&gt; s != null &amp;&amp; !s.isEmpty())
                              .map(s -&gt; lounge.getStringFromOldString(s))
                              .filter(s -&gt; s != null &amp;&amp; !s.isEmpty())
                              .collect(
                                      Collectors
                                              .toCollection(HashSet::new))
  // add list to resulting list
                              .forEach(
                                      s -&gt; {
                                          result.add(new TradeLink(s,
                                                  haveItem, e.getKey()));
                                      });
  
                  });
  </code></pre>