title: Set value for enumerator object of unknown type
body: <p>Let's say we have got a lot of enumerations of types A, B etc..:</p>
  
  <pre><code>public enum A {SOME, STUFF}
  public enum B {OTHER, STUFF}
  ....
  </code></pre>
  
  <p>Now, we have got an object with unknown enum type. Is there any way to set its value? I know that <code>Java</code> is a static type language, but maybe there is a workaround for this?</p>
  
  <p>I tried something like:</p>
  
  <pre><code> public Enum getStuff(Enum unknownEnum, String value) {
       try {
           return Enum.valueOf(unknownEnum.getClass(), value);
       } catch (IllegalArgumentException e) {
           return null;
       }
  
   }
  </code></pre>
  
  <p>But this does not work because valueOf requires a strong type, right? Do you know of any way how to do this in <code>Java</code>?</p>