title: generic Enum.valueOf method : Enum class in parameter and return Enum item
body: <p>I'd like to make a method that implement <code>valueOf</code> on any Enum class passed in parameter (and also wrap some specialized error/missing-name code).
  So basically, I have several Enum such as:</p>
  
  <pre><code>enum Enum1{ A, B, C }
  enum Enum2{ D, E, F }
  </code></pre>
  
  <p>And I want a method that wrap around <code>valueOf</code>. I could not find a way to directly pass an Enum class in parameter on which I could call <code>valueOf</code>. Here is what I came up with:</p>
  
  <pre><code>private static Enum getEnum(Class&lt;Enum&gt; E, String name){
      for(Enum e: E.getEnumConstants())
          if(e.name().equals(name)){
              return e;
          }
      return null;
  }
  </code></pre>
  
  <p>Which I want to call with: <code>getEnum(Enum1,"A")</code>. But it does not like it:</p>
  
  <pre><code>java: cannot find symbol
    symbol:   variable Enum1
    location: class Main
  </code></pre>