Confused in using java generics proper way
<p>I have struck at one point where i am not sure how to move ahead.I have a class with following code</p>

<pre><code>public class MyClass{

  private Class&lt;? extends ValidationProvider&gt; providerClass;
  //getter ans setter

}
</code></pre>

<p>Provider class is being passed at run time and there can be different implementation for that, all it needs to follow the above contract <code>? extends ValidationProvider</code>.</p>

<p>In my implementation i have provided a property where user can pass the provider name class and based on that i need to move ahead.In order to move ahead i need to get an Instance of provider class using the build in dependency injection mechanism like</p>

<pre><code> public class MyClass{

      private Class&lt;? extends ValidationProvider&gt; providerClass;
      //getter ans setter

      public void setProvider(){
         providerClass=container.getInstance("type","name");
      }
    }
</code></pre>

<p>Signature of <code>container.getInstance("type","name");</code> is </p>

<pre><code> &lt;T&gt; T getInstance(Class&lt;T&gt; type, String name);
</code></pre>

<p>i am not sure how to pass type to the container and to get instance of the provider class(since provider class has a signature <code>&lt;? extends ValidationProvider&gt;</code> ).</p>

<p>for simple use case i can do like </p>

<pre><code>container.getInstance(String.class,"my constant");
</code></pre>

<p>but not sure how to do it for my use-case
Any help in this regard will really be appreciated.</p>
