title: Java Generics extending two classes with an enum involved
body: <p>I'm attempting to make an interface for user-defined Enums to implement, so that they can all utilize a common ConfigurationLoader class for their configuration values, however I cannot seem to declare a <code>Class&lt;?&gt;</code> variable that extends two subclasses in the method arguments (jdk 1.8, static methods are possible in interfaces).</p>
  <p>The reason I need to have both is I want to be able to guaruntee that the enum does in fact implement the <code>ConfigMarker</code> interface, but is also an Enum in which I can call <code>values()</code> on. How can I make it understand that it has two subclasses?</p>
  <pre><code>public interface ConfigMarker {
  
      public String getPath();
  
      public Object getDefault();
  
      public static void setDefaults(FileConfiguration file, Class&lt;? extends Enum &amp; ConfigMarker&gt; clazz) {
          try {
              Method m = clazz.getMethod(&quot;values&quot;);
              m.setAccessible(true);
              for (ConfigMarker conf : (ConfigMarker[]) m.invoke(null)) {
                  if (!file.isSet(conf.getPath())) {
                      file.set(conf.getPath(), conf.getDefault());
                  }
              }
          } catch (NoSuchMethodException ex) {
              // numerous other exceptions that are caught, irrelevant.    
          }
      }
  
  }
  </code></pre>
  <p>The specific compile-time error states &quot;Wrong number of type arguments, 1 expected&quot;. I know that it is possible to specify more than one with <code>&amp;</code>, so why is it failing here?</p>
  <h1>Edit</h1>
  <p>Per the answer below, I was able to resolve the type, but I cannot seem to make a call to the method itself:</p>
  <pre><code>public enum ConfigValue implements ConfigMarker {...}
  
  public ConfigurationLoader(Main project, ConfigMarker marker) {
      //...
      marker.setDefaults(file, ConfigValue.SOME_VALUE.getDeclaringClass());
      //or
      marker.setDefaults(file, ConfigValue.class);
  }
  </code></pre>