SysWarningLevelEnums.java
1.1 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package com.skua.modules.util;
import lombok.Getter;
/**
* 系统告警级别
*/
@Getter
public enum SysWarningLevelEnums {
WARNING_LEVEL_1("重要报警",30),
WARNING_LEVEL_2("一般报警",20),
WARNING_LEVEL_3("提醒报警",10);
;
private String value;
//等级(值越大,等级越高)
private Integer level;
SysWarningLevelEnums(String value, Integer level) {
this.value = value;
this.level = level;
}
/**
* 校验【告警级别】是否合法,不合法则返回'提醒告警'
* @param warningLevel
* @return
*/
public static String verifyLevel(String warningLevel){
for (SysWarningLevelEnums e : SysWarningLevelEnums.values()) {
if(e.getValue().equals(warningLevel)){
return e.getValue();
}
}
return WARNING_LEVEL_3.getValue();
}
/**
*
* @param warningLevel 告警等级
* @return
*/
public static SysWarningLevelEnums getByLevel(String warningLevel){
for (SysWarningLevelEnums e : SysWarningLevelEnums.values()) {
if(e.getValue().equals(warningLevel)){
return e;
}
}
return WARNING_LEVEL_3;
}
}