@Test public void testValueOfOrNull() throws Exception { assertThat(Util.valueOfOrNull("error", Level.class), is(Level.error)); assertThat(Util.valueOfOrNull("null", Level.class), is(nullValue())); }
public static <T extends Enum<T>> T valueOfOrNull(String name, Class<T> type) { T ret; try { ret = Enum.valueOf(type, name); } catch (Exception e) { ret = null; } return ret; }
Util { public static <T extends Enum<T>> T valueOfOrNull(String name, Class<T> type) { T ret; try { ret = Enum.valueOf(type, name); } catch (Exception e) { ret = null; } return ret; } }
Util { public static <T extends Enum<T>> T valueOfOrNull(String name, Class<T> type) { T ret; try { ret = Enum.valueOf(type, name); } catch (Exception e) { ret = null; } return ret; } private  Util(); }
Util { public static <T extends Enum<T>> T valueOfOrNull(String name, Class<T> type) { T ret; try { ret = Enum.valueOf(type, name); } catch (Exception e) { ret = null; } return ret; } private  Util(); static T valueOfOrNull(String name, Class<T> type); static T valueOfOrDefault(String name, Class<T> type, T def); static String nameOfOrNull(String name, Class<T> type); }
Util { public static <T extends Enum<T>> T valueOfOrNull(String name, Class<T> type) { T ret; try { ret = Enum.valueOf(type, name); } catch (Exception e) { ret = null; } return ret; } private  Util(); static T valueOfOrNull(String name, Class<T> type); static T valueOfOrDefault(String name, Class<T> type, T def); static String nameOfOrNull(String name, Class<T> type);  }