title: Java - Return correct type from Generic method
body: <p>I have the following class structure:</p>
  
  <pre><code>public class Team {
      ...
  }
  
  public class Event {
  
  }
  
  public abstract class Fixture&lt;T extends Team&gt; implements Event {
     ...
  }
  
  public abstract class Forecast&lt;Event&gt; {
  
  }
  
  public class MyPrediction&lt;T extends Fixture&lt;? extends Team&gt;&gt; extends Forecast&lt;Fixture&lt;? extends Team&gt;&gt;{
  
  }
  </code></pre>
  
  <p>I am trying to model sports events of all kinds (i.e. a 'Fixture' is for a particular game between two participants play against each other, whereas another type of 'Event' may have many participants), along with predictions for the outcome of particular 'Events'. I have a generic method:</p>
  
  <pre><code>public &lt;T&gt; MyPrediction&lt;Fixture&lt;? extends Team&gt;&gt; getMyPrediction(Fixture&lt;? extends Team&gt; fixture) {
  </code></pre>
  
  <p>}</p>
  
  <p>I want to be able to return a <code>MyPrediction</code> instance which has the generic type of the <code>fixture</code> argument, but I can't seem to do so. For example, if I do something like the following, then I get a compilation error:</p>
  
  <pre><code>SoccerFixture&lt;EnglishSoccerTeams&gt; soccerMatch = new ScoccerFixture&lt;EnglishSoccerTeams&gt;();
  MyPrediction&lt;SoccerFixture&lt;EnglishSoccerTeams&gt;&gt; = getMyPrediction(soccerMatch);
  </code></pre>
  
  <p>I am willing to change my class structure to incorporate this feature. How can I do so?</p>