public enum LogLevel {
HIGH("高危"),MEDIUM("中危"),LOW("低危"),INFO("信息");
private String desc;
LogLevel(String desc) {
this.desc = desc;
}
public static Map<String, String> map() {
Map<String, String> map = new HashMap<>();
LogLevel[] values = LogLevel.values();
for (LogLevel logLevel : values) {
map.put(logLevel.name(), logLevel.desc);
}
return map;
}
public static String getDesc(String name) {
if (StringUtils.isEmpty(name)) {
return null;
}
Map<String, String> map = map();
if(!map.containsKey(name)){
return null;
}
LogLevel logLevel = LogLevel.valueOf(name);
if (logLevel == null) {
return null;
}
return logLevel.desc;
}
}