title: Cumbersome generics declaration in a huge Java classes hierarchy
body: <p>I have basically two types of each entity in my project which are distinguisched only by specifying the parent catalog type in the class generics declaration. Catalogs iteself are declared with generics as they can have links to a specific old catalog of the same type.</p>
  
  <pre><code>abstract class AbstractCatalog&lt;T extends AbstractCatalog&lt;T&gt;&gt; {
  
      public abstract T getOld();
  }
  
  class Catalog1 extends AbstractCatalog&lt;Catalog1&gt; {
  
      @Override
      public Catalog1 getOld() { ... }
  }
  
  class Catalog2 extends AbstractCatalog&lt;Catalog2&gt; {
  
      @Override
      public Catalog2 getOld() { ... }
  }
  </code></pre>
  
  <p>So far so good but the problem is that it becomes really cumbersome if I add some entities that must contain a link to a catalog of a certain type.</p>
  
  <p>For instance,</p>
  
  <pre><code>abstract class AbstractCatalogHistory&lt;C extends AbstractCatalog&lt;C&gt;, E extends AbstractHistoryEntry&lt;C, E&gt;&gt; {
  
      public abstract Set&lt;E&gt; getEntries();
  }
  
  abstract class AbstractHistoryEntry&lt;C extends AbstractCatalog&lt;C&gt;, E AbstractHistoryEntry&lt;C, E&gt;&gt; {
  
      public abstract E getPrior();
  }
  
  class Cat1HistoryEntry extends AbstractHistoryEntry&lt;Catalog1, Cat1HistoryEntry&gt; {
  
      @Override
      public Cat1HistoryEntry getPrior() { ... }
  }
  
  class Cat2HistoryEntry extends AbstractHistoryEntry&lt;Catalog2, Cat2HistoryEntry&gt; {
  
      @Override
      public Cat2HistoryEntry getPrior() { ... }
  }
  
  class Catalog1History extends AbstractCatalogHistory&lt;Catalog1, Cat1HistoryEntry&gt; {
  
      @Override
      public Set&lt;Cat1HistoryEntry&gt; getEntries() { ... }
  }
  
  class Catalog2History extends AbstractCatalogHistory&lt;Catalog2, Cat2HistoryEntry&gt; {
  
      @Override
      public Set&lt;Cat2HistoryEntry&gt; getEntries() { ... }
  }
  </code></pre>
  
  <p>so it gets much more difficult to get idea of what's going on while looking at such a hierarchy. This example is by no means complete and I have dozens of types that should be nested within those I provided above.</p>
  
  <p>What I'm trying to do by doing this is to take advantage of type safe code which can be verified at compile time. But at the same time such a code becomes completely messy as I have to specify longer generics chains while adding new types to the hierarchy.</p>
  
  <p>Is there a way to handle such generics explosion?</p>