### Question:
PropertyUtils { public static <T extends Enum<T>> T getEnum(String key, Class<T> type, T defaultValue) { String val = getString(key); if (val == null) { return defaultValue; } try { return Enum.valueOf(type, val); } catch (IllegalArgumentException e) { logger.info(e.getMessage(),e); } return defaultValue; } private  PropertyUtils(); static String getString(String key); static String getString(String key, String defaultVal); static int getInt(String key); static int getInt(String key, int defaultValue); static Boolean getBoolean(String key); static long getLong(String key); static long getLong(String key, long defaultVal); static double getDouble(String key); static double getDouble(String key, double defaultVal); static String[] getArray(String key, String splitStr); static T getEnum(String key, Class<T> type,
                                         T defaultValue);  }### Answer:
@Test public void testGetEnum() { ZKNodeType zkNodeType = PropertyUtils.getEnum("test.server.enum1", ZKNodeType.class,ZKNodeType.WORKER); assertEquals(zkNodeType, ZKNodeType.MASTER); zkNodeType = PropertyUtils.getEnum("test.server.enum2", ZKNodeType.class,ZKNodeType.WORKER); assertEquals(zkNodeType, ZKNodeType.DEAD_SERVER); zkNodeType = PropertyUtils.getEnum(null, ZKNodeType.class,ZKNodeType.WORKER); assertEquals(zkNodeType, ZKNodeType.WORKER); zkNodeType = PropertyUtils.getEnum("test.server.enum3", ZKNodeType.class,ZKNodeType.WORKER); assertEquals(zkNodeType, ZKNodeType.WORKER); }