title: Converting Collection to LinkedHashMap with Streams API, getting "Cyclic inference" error
body: <p>I need to implement a method that converts a <code>Collection&lt;String&gt;</code> into <code>LinkedHashMap&lt;String, String&gt;</code>,
  in such way, that in the returned Map every <code>key</code> is equal to the <code>value</code>.</p>
  
  <p>For example this list:</p>
  
  <pre><code>{ "one", "two", "three" }
  </code></pre>
  
  <p>would be converted into that map:</p>
  
  <pre><code>{ {"one":"one"}, {"two":"two"}, {"three":"three"} }
  </code></pre>
  
  <hr>
  
  <p>The solution I currently have is pretty straightforward - I'm constructing a new instance of the <code>LinkedHashMap</code>,
  iterating through the <code>Collection</code>, and putting every <code>String</code> into the <code>Map</code> as both <code>key</code> and <code>value</code>:</p>
  
  <pre><code>public LinkedHashMap&lt;String, String&gt; collectionToMapJava7(Collection&lt;String&gt; collection) {
      LinkedHashMap&lt;String, String&gt; linkedHashMap = new LinkedHashMap&lt;String, String&gt;();
      for (String s : collection) {
          linkedHashMap.put(s, s);
      }
      return linkedHashMap;
  }
  </code></pre>
  
  <p>That solution works well enough, but since my project is already using <strong>Java 8</strong>,
  I wanted to get to know the new features, namely <code>Stream</code> and <code>Collectors</code>.</p>
  
  <p>Unfortunately I've run into a problem that's little confusing:</p>
  
  <p>I'm taking a <code>Stream</code> from the <code>Collection</code>, calling a <code>toMap</code> collector, mapping both <code>key</code> and <code>value</code> with the same element,
  and my IDE (IntelliJ IDEA 15.0.4) spits out the vague "Cyclic inference" error on the marked line:</p>
  
  <pre><code>public LinkedHashMap&lt;String, String&gt; collectionToMapJava8(Collection&lt;String&gt; collection) {
      return collection.stream().collect(Collectors.toMap(s-&gt;s, s-&gt;s));
  }                                                       ̃ ̃ ̃ ̃   ̃ ̃ ̃ ̃
  </code></pre>
  
  <hr>
  
  <p>As far as I know after reading a couple of questions about this error, it usually strikes when you
  <a href="https://stackoverflow.com/questions/33034307/java-collect-function-gives-cyclic-inference-error">use a Collector with wrong resulting type</a>, but I cannot lower the type constraints and use a plain <code>Map</code> interface.</p>
  
  <p><strong>My question is</strong>: how can I convert a <code>Collection</code> into a <code>LinkedHashMap</code> with the Java Streams API?</p>