Here you can find the source of getDataInEnumClass(String enumClassName)
@SuppressWarnings("unchecked") public static HashMap<String, String> getDataInEnumClass(String enumClassName)
//package com.java2s; //License from project: Open Source License import java.util.EnumSet; import java.util.HashMap; public class Main { @SuppressWarnings("unchecked") public static HashMap<String, String> getDataInEnumClass(String enumClassName) { try {// ww w.jav a 2 s. c om @SuppressWarnings("rawtypes") Class clazz = Class.forName(enumClassName); // Object enumObj = Class.forName(fullClassName).newInstance(); if (clazz.isEnum()) { return getDataFromEnum(clazz); } } catch (ClassNotFoundException e) { //DO nothing, just return empty map in the end } return new HashMap<String, String>(); } /** * This method return all enums in class. * @param enumClass from which will be extracted enums. * @return HashMap of value in enum. Key is enum name and concrete value is Enum.toString() result. */ private static <E extends Enum<E>> HashMap<String, String> getDataFromEnum(Class<E> enumClass) { HashMap<String, String> enumValues = new HashMap<String, String>(); for (E enumField : EnumSet.allOf(enumClass)) { String key = enumField.name(); String value = enumField.toString(); enumValues.put(key, value); } return enumValues; } }