title: Restricting types in a generic class
body: <p>This is my first time working with generics, so I'm a little unfamiliar with the terminology. Anyway, supposing I'm creating my own implementation of AbstractList:</p>
  
  <p><code>class MyList&lt;T&gt; extends AbstractList&lt;T&gt;</code></p>
  
  <p>And I've got the following three classes that I cannot change:</p>
  
  <pre><code> class TestNumber
   class One extends TestNumber
   class Two extends TestNumber
   class Three extends TestNumber
   // etc...
  </code></pre>
  
  <p>Is it possible to change the type parameter for <code>MyList</code> to allow only types <code>One</code> and <code>Two</code>, but not other classes that inherit from <code>TestNumber</code>?</p>