提交 | 用户 | 时间
|
ce910c
|
1 |
package com.netsdk.lib.enumeration; |
H |
2 |
|
|
3 |
/** |
|
4 |
* 单个平台接入启动选项 |
|
5 |
* |
|
6 |
* @author 47040 |
|
7 |
* @version 1.0.0 |
|
8 |
* @since Created in 2021/3/9 8:42 |
|
9 |
*/ |
|
10 |
public enum EM_SERVER_OPTION { |
|
11 |
/** |
|
12 |
* 未知 |
|
13 |
*/ |
|
14 |
EM_SERVER_OPTION_UNKNOWN(0, "未知"), |
|
15 |
/** |
|
16 |
* 平台接入不启动 |
|
17 |
*/ |
|
18 |
EM_SERVER_OPTION_DISABLE(1, "平台接入不启动"), |
|
19 |
/** |
|
20 |
* 以28181接入方式开启 |
|
21 |
*/ |
|
22 |
EM_SERVER_OPTION_GB28181(2, "以28181接入方式开启"), |
|
23 |
/** |
|
24 |
* 以35114接入方式开启 |
|
25 |
*/ |
|
26 |
EM_SERVER_OPTION_GB35114(3, "以35114接入方式开启"); |
|
27 |
|
|
28 |
/** |
|
29 |
* 枚举值 |
|
30 |
*/ |
|
31 |
private final int value; |
|
32 |
/** |
|
33 |
* 枚举描述 |
|
34 |
*/ |
|
35 |
private final String note; |
|
36 |
|
|
37 |
EM_SERVER_OPTION(int givenValue, String note) { |
|
38 |
this.value = givenValue; |
|
39 |
this.note = note; |
|
40 |
} |
|
41 |
|
|
42 |
public String getNote() { |
|
43 |
return note; |
|
44 |
} |
|
45 |
|
|
46 |
public int getValue() { |
|
47 |
return value; |
|
48 |
} |
|
49 |
|
|
50 |
/** |
|
51 |
* 依据枚举值返回描述 |
|
52 |
* |
|
53 |
* @param givenValue 枚举值 |
|
54 |
* @return 对应描述 |
|
55 |
*/ |
|
56 |
public static String getNoteByValue(int givenValue) { |
|
57 |
for (EM_SERVER_OPTION enumType : EM_SERVER_OPTION.values()) { |
|
58 |
if (givenValue == enumType.getValue()) { |
|
59 |
return enumType.getNote(); |
|
60 |
} |
|
61 |
} |
|
62 |
return null; |
|
63 |
} |
|
64 |
|
|
65 |
/** |
|
66 |
* 依据描述返回枚举值 |
|
67 |
* |
|
68 |
* @param givenNote 枚举描述 |
|
69 |
* @return 对应枚举值 |
|
70 |
*/ |
|
71 |
public static int getValueByNote(String givenNote) { |
|
72 |
for (EM_SERVER_OPTION enumType : EM_SERVER_OPTION.values()) { |
|
73 |
if (givenNote.equals(enumType.getNote())) { |
|
74 |
return enumType.getValue(); |
|
75 |
} |
|
76 |
} |
|
77 |
return -1; |
|
78 |
} |
|
79 |
|
|
80 |
/** |
|
81 |
* 依据枚举值返回枚举类型 |
|
82 |
* |
|
83 |
* @param value 枚举值 |
|
84 |
* @return 对应枚举类型 |
|
85 |
*/ |
|
86 |
public static EM_SERVER_OPTION getEnum(int value) { |
|
87 |
for (EM_SERVER_OPTION e : EM_SERVER_OPTION.values()) { |
|
88 |
if (e.getValue() == value) |
|
89 |
return e; |
|
90 |
} |
|
91 |
return EM_SERVER_OPTION.EM_SERVER_OPTION_UNKNOWN; |
|
92 |
} |
|
93 |
|
|
94 |
} |