lyfO_o
2022-02-10 aee83e0836bfa9647b9bc3dc39644dc8ca66912f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.nanometer.smartlab.entity.enumtype;
 
import java.util.HashMap;
 
public enum WarningLevel {
    WARN(1, "警告"),
    ERROR(2, "错误"),
    FATAL(3, "危险"),
    MORE_FATAL(4, "严重危险");
 
    private int levelCode;
 
    private String levelMsg;
 
    private WarningLevel(int levelCode, String levelMsg) {
        this.levelCode = levelCode;
        this.levelMsg = levelMsg;
    }
 
    public int getLevelCode() {
        return levelCode;
    }
 
    public String getLevelMsg() {
        return levelMsg;
    }
 
    private static HashMap<Integer,WarningLevel> map = new HashMap<Integer,WarningLevel>();
    static {
        for(WarningLevel d : WarningLevel.values()){
            map.put(d.levelCode, d);
        }
    }
 
    public static WarningLevel parse(Integer index) {
        if(map.containsKey(index)){
            return map.get(index);
        }
        return null;
    }
}