title: Correct way to instantiate a generic class
body: <p>Weak in generic, please go easy! <br />
  I have some base and derived classes structured as below via generics</p>
  <pre><code>public abstract class ProcessingNode&lt;T extends APICommand&gt; extends Node {
  }
  
  public class CustomerProcessingNode extends ProcessingNode&lt;CHDAPICommand&gt; {
  }
  
  public class MerchantProcessingNode extends ProcessingNode&lt;MHDAPICommand&gt; {
  }
  
  public class APICommand {
  }
  
  public class CHDAPICommand extends APICommand {
  }
  
  public class MHDAPICommand extends APICommand {
  }
  </code></pre>
  <p>Now, during server start i would want to pick the right <code>ProcessingNode</code> and cache it as below:</p>
  <pre><code>private void cacheProcessingNodeManager() throws ListenerException {
      // throws Unexpected Bound error
      ProcessingNode&lt;T extends APICommand&gt; processingNodeManager = null;      
      if (condition1 is true){
          // throws &quot;required ProcessingNode&lt;T&gt; but found CustomerProcessingNode&quot;
          processingNodeManager = new CustomerProcessingNode();               
      }
      else if (condition2 is true){
          // throws &quot;required ProcessingNode&lt;T&gt; but found MerchantProcessingNode&quot;
          processingNodeManager = new MerchantProcessingNode();               
      } else {
          // some exception
      }
      // cache processingNodeManager
  }       
  </code></pre>
  <p>but i get 2 error as highlighted in comments above.</p>
  <p>What would be the right way to create specific objects of <code>ProcessingNode</code>?</p>