common-models/src/main/java/eu/eudat/commonmodels/enums/EnumUtils.java

15 lines
469 B
Java

package eu.eudat.commonmodels.enums;
import java.util.HashMap;
import java.util.Map;
public class EnumUtils {
public static <EnumType extends Enum<EnumType> & EnumValueProvider<EnumValue>, EnumValue> Map<EnumValue, EnumType> getEnumValueMap(Class<EnumType> enumType){
HashMap<EnumValue, EnumType> map = new HashMap<>();
for (EnumType v : enumType.getEnumConstants()) {
map.put(v.getValue(), v);
}
return map;
}
}