title: Java Generic Class - Determine Type
body: <p>If I am creating a java class to be generic, such as:  </p>
  
  <pre><code>public class Foo&lt;T&gt;
  </code></pre>
  
  <p>How can one determine internally to that class, what 'T' ended up being? </p>
  
  <pre><code>public ???? Bar()
  {
      //if its type 1
      //    do this
      //if its type 2
      //    do this
      //if its type 3
      //    do this
      //if its type 4
      //    do this
  }
  </code></pre>
  
  <p>I've poked around the Java API and played with the Reflection stuff, instanceof, getClass, .class, etc, but I can't seem to make heads or tails of them. I feel like I'm close and just need to combine a number of calls, but keep coming up short.</p>
  
  <p>To be more specific, I am attempting to determine whether the class was instantiated with one of 3 possible types.</p>