title: Dynamically Loading Both a Java Enum Class and an Enum Constant
body: <p>I've seen many StackOverflow posts on how to dynamically get an enum's value given that you know the Enum class at compile time, but I'm trying to dynamically load the enum class and an enum value, and I'm not seeing how to do this.</p>
  
  <p>I'm trying to do something like this:</p>
  
  <pre><code>public interface Config {
      public ConfigValue getConfigValue();
  }
  
  public enum AwsConfig implements Config {
      ACCESS_KEY_ID( new ConfigValue(...) ),
      API_URL( new ConfigValue(...) )
      ...
      public static String getName() { return "AwsConfig"; }
      ...
  }
  
  public enum PaginatorConfig implements Config {
      DEFAULT_PAGE_SIZE( new ConfigValue(...) ),
      ...
      public static String getName() { return "PaginatorConfig"; }
      ...
  }
  
  public void myMethod( ConfigValue configValue ) {
      String enumClassName = configValue.getName();
      String enumConstantKeyName = configValue.getKey();
  
      // I now have the enum's class name as enumClassName
      // I now have the enum constant's name as enumConstantKeyName
      // How can I dynamically get the enum constant's configValue based on the enumClassName and enumConstantKeyName?
  
      // I know I can get the value dynamically if I know the Enum constant...
      ConfigValue configValue = AwsConfig.valueOf("API_URL")
  
      // But I wish I could do something like this...
      ConfigValue configValue = Enum.valueOf( "AwsConfig", "API_URL" );
  }
  </code></pre>