### Question:
EnumUtil { public static <T extends Enum<T>> T valueOf(Class<T> cls, String name, T defaultValue) { try{ return Enum.valueOf(cls, name); }catch(IllegalArgumentException e){ return defaultValue; } }  static T getEnumById(Class<T> cls, K id, T defaultEnum); @SuppressWarnings({ "rawtypes", "unchecked" }) static T getEnumById(Class<T> cls, K id); static T getEnumByIdString(Class<T> cls, String id); static T valueOf(Class<T> cls, String name, T defaultValue); @SuppressWarnings({ "rawtypes", "unchecked" }) static T valueOf(Class<T> cls, String name); static Enum<?> getDefaultValue(Class<Enum<?>> cls); static EnumSet<T> toEnumSet(long f, Class<T> cls); static long toLong(EnumSet<T> enums);  }### Answer:
@Test public void testValueOf() { assertSame(TestEnum.value1, TestEnum.getByName("value1")); assertSame(TestEnum.value4, TestEnum.getByName("value4")); assertSame(TestEnum.unknown, TestEnum.getByName("value10")); }