title: Using collectingAndThen() with Collectors.toMap() requires explicit type cast
body: <p>I have a <code>Map&lt;String,BigDecimal&gt;</code> (say amountMap) which I want to convert to an <code>ImmutableMap&lt;String,Double&gt;</code>, code for which is:</p>
  
  <pre><code>return amountMap.entrySet().stream()
          .collect(collectingAndThen(toMap(e-&gt;e.getKey(),e-&gt;e.getValue().doubleValue()),ImmutableMap::copyOf));
  </code></pre>
  
  <p>However Eclipse shows an error which says that e.getKey() and e.getValue() require explicit type casting since they are of type Object.</p>
  
  <p>The same code works when I split it like so:</p>
  
  <pre><code>Map&lt;String,Double&gt; tempMap = amountMap.entrySet().stream()
                                  .collect(toMap(e-&gt;e.getKey(),e-&gt;e.getValue().doubleValue());
  
  return ImmutableMap.copyOf(tempMap);
  </code></pre>
  
  <p>I am assuming the former error is because of Type Erasure, but if not, is there a way to return the Map as an ImmutableMap without the intermediate step of creating a temporary map to hold the results ?</p>