Java String Value Of valueOfEnum(final Class type, final String value)

Here you can find the source of valueOfEnum(final Class type, final String value)

Description

Find the enum value of the given enum type with the given identifier (name).

License

Open Source License

Parameter

Parameter Description
type The enum type for which to obtain a value.
value The name of the enum value to obtain.
T The enum type for which to obtain a value.

Exception

Parameter Description
IllegalArgumentException if the given enum type has no member named by the given value.

Return

The enum value.

Declaration

public static <T extends Enum<T>> T valueOfEnum(final Class<T> type, final String value) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**// w  ww.ja v a  2s  .com
     * Find the enum value of the given enum type with the given identifier (name).
     *
     * @param type  The enum type for which to obtain a value.
     * @param value The name of the enum value to obtain.
     * @param <T>   The enum type for which to obtain a value.
     *
     * @return The enum value.
     *
     * @throws IllegalArgumentException if the given enum type has no member named by the given value.
     */
    public static <T extends Enum<T>> T valueOfEnum(final Class<T> type, final String value) {

        return Enum.valueOf(type, value);
    }
}

Related

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