title: Nested class cannot be cast to java.lang.reflect.ParameterizedType
body: <p>I am trying to implement model structure like this:</p>
  
  <pre><code>Generic (abstract)
  TplInsurance (extends Generic)
  TplInsuranceDoctor (nested class in TplInsurance extends TplInsurance)
  </code></pre>
  
  <p>Unfortunatelly I am getting runtime error when I am trying to create object of <code>TplInsuranceDoctor</code>, wich is nested class:</p>
  
  <pre><code>Caused by: java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType
  </code></pre>
  
  <p>That errors points to Generic contructor:</p>
  
  <pre><code>public Generic() {
      entityClass = ((Class) ((Class) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]));
  }
  </code></pre>
  
  <p>Here are model classes:</p>
  
  <pre><code>public abstract class Generic&lt;T extends Generic&gt; {
      protected Class&lt;T&gt; entityClass;
      public Generic() {
          entityClass = ((Class) ((Class) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]));
      }
      public Long id;
  }
  </code></pre>
  
  <hr>
  
  <pre><code>public class TplInsurance extends GenericDictionary&lt;TplInsurance&gt; {
  
      public class TplInsuranceDoctor extends TplInsurance {
          public final String color = "success";
          public final String title = "lekarza i dentysty";
      }
  </code></pre>
  
  <p>Here is The way I create object:</p>
  
  <pre><code>TplInsuranceDoctor tDoctor = new TplInsurance().new TplInsuranceDoctor();
  </code></pre>
  
  <hr>
  
  <p>I understand That I should somehow parametrise type of nested class <code>TplInsuranceDoctor</code>, but I dont know how. Everything I've tried fail compilation. Please help</p>