Java String Value Of valueOfIC(Class enumType, String aName)

Here you can find the source of valueOfIC(Class enumType, String aName)

Description

Returns an enum for enum class and string, ignoring case.

License

Open Source License

Declaration

public static <T extends Enum<T>> T valueOfIC(Class<T> enumType, String aName) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from   ww w . j  a v a2s. c  o  m
     * Returns an enum for enum class and string, ignoring case.
     */
    public static <T extends Enum<T>> T valueOfIC(Class<T> enumType, String aName) {
        for (T value : enumType.getEnumConstants())
            if (value.toString().equalsIgnoreCase(aName))
                return value;
        if (aName == null)
            throw new NullPointerException("Name is null");
        throw new IllegalArgumentException("No enum const " + enumType + "." + aName);
    }
}

Related

  1. valueOfBoolean(final String s)
  2. valueOfBoolean(String string)
  3. valueOfBooleanStr(String str)
  4. valueOfEnum(Class enumClass, String value, E defaultValue)
  5. valueOfEnum(final Class type, final String value)
  6. valueOfIgnoreCase(Class cls, String value)
  7. valueOfIgnoreCase(Class enumType, String constantName)
  8. valueOfInteger(final String s, int radix)
  9. valueOfIpv4(String ip)