title: Java: How to get values from an arbitrary Enum class
body: <p>I have an enum containing reference to a class of enum like so:</p>
  <pre><code>enum Animal { 
    DOG(DayOfWeek.class),
    CAT(Month.class);
  
    public Class&lt;? extends Enum&gt; clazz;
  
    Animal(Class&lt;? extends Enum&gt; c) {
      this.clazz = c;
    }
  
    public String getValuesConcat() {
      String allValues = &quot;&quot;;
  
      // The following line doesn't compile
      for (Object enumValue : EnumSet.allOf(clazz)) {
        allValues += &quot; &quot; + enumValue.toString();
      }
  
      return allValues;
    }
  }
  </code></pre>
  <p>I couldn't figure out a way to store Enum class so that I can get the list of values from it later. Any clues?</p>