public static <T extends Enum<T>> T convert(Class<T> type, String name, T defaultValue) {
        if (name == null) {
            return defaultValue;
        }

        for (T e : type.getEnumConstants()) {
            if (e.name().equalsIgnoreCase(name)) {
                return e;
            }
        }

        return defaultValue;
    }
public static < T extends Enum < T > > T convert ( Class < T > type , String name , T defaultValue ) { if ( name == null ) { return defaultValue ; } for ( T e : type . getEnumConstants ( ) ) { if ( e . name ( ) . equalsIgnoreCase ( name ) ) { return e ; } } return defaultValue ; }
Searches for enum of given class with given name (case insensitive).

@param type Enum class
@param name Enum constant name
@param defaultValue Default value if no enum constant with given name is found