title: Java nested wildcard bound types multiple times or as generic type parameter
body: <p>I have a class with a bounded type parameter with nested wildcard bounded types.  In the class I need to use the types of the bound nested parameters in multiple methods. Is there a way to define the wildcard bounded type as a generic type parameter instead or assign it to a generic variable name so that it can easily be referenced in multiple places?</p>
  
  <p>The way the class is implemented now is like</p>
  
  <pre><code>    class AbstractManager&lt;F extends Filter&lt;? extends Criteria&lt;? extends Type&gt;&gt;&gt;
      {
         protected void setFilter(F filter)
         {
           setCriteria(f.getCriteria());
         }
  
         protected &lt;T extends Criteria&lt;? extends Type&gt;&gt; void setCriteria(List&lt;T&gt; criteria)
         {   
         }
  
         protected &lt;T extends Criteria&lt;? extends Type&gt;&gt; void doSomethingWithCriteria(List&lt;T&gt; criteria)
         {
            ...
         }
      }
  </code></pre>
  
  <p>which does not bound actually restrict the type of the list to the type of the Filter but is good enough in our situation. Ideally the type of the list would be restricted to the type of the filter using a construct that could bind the inferred type of the filter to a name much like a bounded type parameter on a method but at the class level instead.</p>
  
  <p>Basically I would like to do something like</p>
  
  <pre><code>    class &lt;G extends Criteria&lt;? extends Type&gt; AbstractManager&lt;F extends Filter&lt;G&gt;&gt;
  </code></pre>
  
  <p>From what I know and can find, this is not possible, but I was hoping that maybe there was an obscure feature or new feature in java 7 that would make this possible.
  I know it is possible to specify a second type parameter like</p>
  
  <pre><code>    class AbstractManager&lt;F extends Filter&lt;G&gt;, G extends Criteria&lt;? extends Type&gt;&gt;
  </code></pre>
  
  <p>but I do not want the child classes to have to specify G when the compiler can determine it.</p>
  
  <p>The only possible option/solution I have been able to find is to have a shallow subclass with factory methods given in the <a href="https://stackoverflow.com/a/8058495/908961">solution</a> to this question
  <a href="https://stackoverflow.com/questions/8058470/nested-type-parameters-in-java">Nested Type Parameters in Java</a>
  and in
  <a href="https://stackoverflow.com/questions/5676567/java-generics-use-same-wildcard-multiple-times">Java generics - use same wildcard multiple times</a></p>