title: Guice: How do I get an instance of a TypeLiteral-wrapped generic?
body: <p>I have a generic database access class, which i'm binding using the TypeLiteral construct. Now in a test i want to mock that class and i have therefor created a Provider, that creates a mock instance. In my test, i want to access that mock to define its behaviour.
  Now the question is, how can i retrieve the object from the injector?</p>
  
  <p>That's my binding definition:</p>
  
  <pre><code>binder.bind(new TypeLiteral&lt;GenericDbClass&lt;Integer&gt;&gt;(){}).GenericDbClassProvider.class);
  </code></pre>
  
  <p>Normally i would get an instance like this:</p>
  
  <pre><code>injector.getInstance(GenericDbClass.class);
  </code></pre>
  
  <p>But since i'm not binding the implementation of GenericDbClass to the Interface itself, i don't know how to do that. Do I think to complicated?</p>
  
  <p>Any ideas/help is greatly appreciated!</p>