title: Populate a map conditionally using streams - Java 8
body: <p>I'm trying to translate this (simplified) code to use Java-8 streams:</p>
  
  <pre><code>Map&lt;String, String&gt; files = new ConcurrentHashMap&lt;String, String&gt;();
  
  while(((line = reader.readLine()) != null) {
        if(content != null)
          files.put("not null"+line, "not null"+line);
        else
          files.put("its null"+line, "its null"+line);
      }
  reader.close();
  </code></pre>
  
  <p>Here is what I've tried:</p>
  
  <pre><code>files = reader.lines().parallel().collect((content != null)?
                  (Collectors.toConcurrentMap(line-&gt;"notnull"+line, line-&gt;line+"notnull")) :                                              
                  (Collectors.toConcurrentMap(line-&gt;line+"null", line-&gt;line+"null")));
  </code></pre>
  
  <p>But the above gives a "cyclic inference" message for all the <code>line-&gt;line+"..."</code> on intelliJ. What is cyclic inference? Is there an error in this logic?</p>
  
  <p>I noted some similar issues on SO. But they suggest to use interface(Map) instead of its implementations. But <code>files</code> here is declared as a <code>Map</code>.</p>
  
  <p>Update: Adding more context, <code>content</code> is a String that holds the name of a directory. <code>files</code> is a map that holds multiple file paths. What file paths need to go into the <code>files</code> map depends on <code>content</code> directory-name is populated or not. </p>