title: Java 8 stream agregate generic list to map
body: <p>I am trying to get myself used with the Java 8 stream functionality by applying it in a small home project. Recently I had the issue reproduced below and despite the fact I understand what the issue is I  could not find the fix. I am posting it here hoping to get some explanations and the correct solution.</p>
  
  <pre><code>public class GroupingByStreamTest {
      class Double&lt;A, B&gt; {
          A a;
          B b;
  
          public Double(A a, B b) {
              this.a = a;
              this.b = b;
          }
      }
  
      class Triple&lt;A, B, C&gt; extends Double&lt;A, B&gt; {
          C c;
  
          public Triple(A a, B b, C c) {
              super(a, b);
              this.c = c;
          }
      }
  
      @Test
      public void shouldGroupToMap() throws Exception {
          List&lt;Triple&lt;String, String, String&gt;&gt; listOfTriples = asList(
              new Triple&lt;&gt;("a-1", "b-1", "c-1"),
              new Triple&lt;&gt;("a-1", "b-2", "c-2"),
              new Triple&lt;&gt;("a-1", "b-3", "c-3"),
              new Triple&lt;&gt;("a-2", "b-4", "c-4"),
              new Triple&lt;&gt;("a-2", "b-5", "c-5"));
  
          // This code below compiles and executes OK. If I put a   breakpoint
          // in my EDI I can even see the expected Map being created. However
          // if you uncomment the line below and comment the one after it the
          // code will no longer compile. 
  
          // Map&lt;String, List&lt;Double&lt;String, String&gt;&gt;&gt; myMap =
          Map&lt;Object, List&lt;Double&lt;Object, Object&gt;&gt;&gt; myMap =
          listOfTriples.stream().collect(groupingBy(t -&gt; t.a,
              mapping((Triple t) -&gt; new Double&lt;&gt;(t.b, t.c),toList())));
  
          assertEquals(2, myMap.size());
      }
  }
  </code></pre>
  
  <p>The compile error I got is </p>
  
  <pre><code>Error:(49, 39) java: incompatible types: inference variable A has incompatible bounds
  equality constraints: java.lang.String
  lower bounds: java.lang.Object
  </code></pre>