private static < T extends Enum < T > > T stringToEnum ( String value , Class < T > type ) { final String s = blankToNull ( value ) ; return value == null ? null : Enum . valueOf ( type , s . toUpperCase ( ) ) ; }
Transform a string into an enum ( using its name which is supposed to be uppercase handles null values .