Here you can find the source of getDataFromEnum(Class
Parameter | Description |
---|---|
enumClass | from which will be extracted enums. |
private static <E extends Enum<E>> HashMap<String, String> getDataFromEnum(Class<E> enumClass)
//package com.java2s; //License from project: Open Source License import java.util.EnumSet; import java.util.HashMap; public class Main { /**/*from www . j ava 2 s .c om*/ * 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; } }