title: How to avoid generic in hierarchy of classes?
body: <p>I have next hierarchy of classes</p>
  
  <pre><code>   class MyObject {
  
  }
  
  class FirstChild extends MyObject {
  
  }
  
  class SecondChild extends MyObject {
  
  }
  
  class Calculator&lt;T extends MyObject&gt; {
      public Integer calculateValue(T supperObject) {
          return 10;
      }
  }
  
  class IntegerCalculator extends Calculator&lt;FirstChild&gt; {
      @Override
      public Integer calculateValue(FirstChild supperObject) {
          return super.calculateValue(supperObject);
      }
  }
  
  class SecondChildCalculator extends Calculator&lt;SecondChild&gt; {
      @Override
      public Integer calculateValue(SecondChild supperObject) {
          return super.calculateValue(supperObject);
      }
  }
  
  
  class AbstractUsefulService {
      protected Calculator&lt;? extends MyObject&gt; calculator;
  
      public AbstractUsefulService(
          Calculator&lt;? extends MyObject&gt; calculator
      ) {
          this.calculator = calculator;
      }
  }
  
  class ImplementationOfAbstractUsefulService extends AbstractUsefulService{
  
      public ImplementationOfAbstractUsefulService(
          SecondChildCalculator calculator
      ) {
          super(calculator);
      }
  
      public void doJob(){
          calculator.calculateValue(new SecondChild());
      }
  }
  </code></pre>
  
  <p>I have a big problem here  calculator.calculateValue(new SecondChild()); - required ? extends MyObject but found SecondChild. I've read a lot of articles and found only one solution and a generic to AbstractUsefulService and use this generic in ConnectionService, but I don't want to do it. How can I resolve my problem without generic in AbstractUsefulService?</p>