title: Get Enum Instance from Class<? extends Enum> using String value?
body: <p>I'm finding it difficult to put the exact question into words, so I'll just give an example.</p>
  
  <p>I have two <code>Enum</code> types:</p>
  
  <pre><code>enum Shape {
      CAT, DOG;
  }
  
  enum Color {
      BLUE, RED;
  }
  </code></pre>
  
  <p>I have a method:</p>
  
  <pre><code>public Object getInstance(String value, Class&lt;?&gt; type);
  </code></pre>
  
  <p>I would like to use the method like:</p>
  
  <pre><code>// someValue is probably "RED", and someEnumClass is probably Color.class
  Color c = getInstance(someValue, someEnumClass);
  </code></pre>
  
  <p>I've been having trouble determining exactly how to implement <code>getInstance()</code>. Once you know the exact <code>Enum</code> class that you want to instantiate, it's easy:</p>
  
  <pre><code>Color.valueOf("RED");
  </code></pre>
  
  <p>But how can this above line be accomplished with an unknown <code>Class</code>? (It is, however, known that the <code>someEnumClass</code> is a subclass of <code>Enum</code>.)</p>
  
  <p>Thanks!</p>