code: private <T extends Enum<T>> T getEnumValue(Class<T> enumType, String name) {
      T[] constants = enumType.getEnumConstants();
      if (constants == null) {
        throw new IllegalArgumentException(enumType.getName() + " is not an enum type");
      }
      for (T constant : constants) {
        if (constant.name().equalsIgnoreCase(name.replace('-', '_'))) {
          return constant;
        }
      }
      // same error that's thrown by Enum.valueOf()
      throw new IllegalArgumentException(
          "No enum constant " + enumType.getCanonicalName() + "." + name);
    }
docs: Behaves like {@link java.lang.Enum#valueOf}, except that {@code name} is case-insensitive and
  hyphen-insensitive (hyphens can be used in place of underscores). This allows for greater
  flexibility when specifying enum types as command-line arguments.
  
  @param <T> the enum type whose constant is to be returned
  @param enumType the Class object of the enum type from which to return a constant
  @param name the name of the constant to return
  @return the enum constant of the specified enum type with the specified name