ClassUtils { public static String[] getEnumStrings(Class klass) { if(!klass.isEnum()) { return null; } ArrayList<String> values = new ArrayList<String>(); try { Method methodName = klass.getMethod("name"); for(Object constant : klass.getEnumConstants()) { values.add((String) methodName.invoke(constant)); } } catch (Exception e) { LOG.error("Can't get list of values from enumeration " + klass.getCanonicalName(), e); return null; } return values.toArray(new String[values.size()]); } private  ClassUtils(); static Class<?> loadClass(String className); static Object instantiate(String className, Object ... args); static Object instantiate(Class klass, Object ... args); static String jarForClass(String className); static String jarForClass(Class klass); static String[] getEnumStrings(Class klass);  }
@Test public void testGetEnumStrings() { assertNull(ClassUtils.getEnumStrings(A.class)); assertArrayEquals( new String[]{"A", "B", "C"}, ClassUtils.getEnumStrings(EnumA.class) ); assertArrayEquals( new String[]{"X", "Y"}, ClassUtils.getEnumStrings(EnumX.class) ); }