Here you can find the source of valueOfEnum(final Class
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. |
Parameter | Description |
---|---|
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)
//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); } }