title: Construct a Map using object reference as key using Streams API and Collectors.toMap()
body: <p>I want to construct a <code>Map&lt;Item, List&lt;String&gt;&gt;</code>, i.e. using the <code>Item</code> reference as key, with some arbitrary <code>List&lt;String&gt;</code> as value. I've attempted the following, but it will show type inference error in IntelliJ (however, it will still <em>compile</em>);</p>
  
  <pre><code>List&lt;Item&gt; items = getItems(...);
  Map&lt;Item, List&lt;String&gt;&gt; itemMap = items.stream().collect(Collectors.toMap(i-&gt;i, new ArrayList&lt;&gt;()));
  </code></pre>
  
  <p>I then created a workaround through a helper method in <code>Item</code>, <code>get()</code>, which just returns its own instance;</p>
  
  <pre><code>public Item get(){ return this; }
  </code></pre>
  
  <p>Then tried the same approach, using the <code>get()</code> method to access the reference:</p>
  
  <pre><code>List&lt;Item&gt; items = getItems(...);
  Map&lt;Item, List&lt;String&gt;&gt; itemMap = items.stream().collect(Collectors.toMap(Item::get, new ArrayList&lt;&gt;()));
  </code></pre>
  
  <p>Now it will at least compile, but it <em>feels wrong</em>. </p>
  
  <p>How would one actually go around solving this in a proper manner?</p>
  
  <p>Edit: Question is now radically different from what was originally posted, reflected by the comments received.</p>