提交 | 用户 | 时间
|
149dd0
|
1 |
package com.iailab.netsdk.lib.enumeration; |
H |
2 |
|
|
3 |
/** |
|
4 |
* 设备需要展示的颜色 |
|
5 |
*/ |
|
6 |
public enum EM_SHOW_COLOR { |
|
7 |
/** |
|
8 |
* 未知 |
|
9 |
*/ |
|
10 |
EM_SHOW_COLOR_UNKNOWN(0, "未知"), |
|
11 |
/** |
|
12 |
* 蓝 |
|
13 |
*/ |
|
14 |
EM_SHOW_COLOR_BLUE(1, "蓝"), |
|
15 |
/** |
|
16 |
* 黄 |
|
17 |
*/ |
|
18 |
EM_SHOW_COLOR_YELLOW(2, "黄"), |
|
19 |
/** |
|
20 |
* 橙 |
|
21 |
*/ |
|
22 |
EM_SHOW_COLOR_ORANGE(3, "橙"), |
|
23 |
/** |
|
24 |
* 红 |
|
25 |
*/ |
|
26 |
EM_SHOW_COLOR_RED(4, "红"); |
|
27 |
|
|
28 |
private int value; |
|
29 |
|
|
30 |
private String note; |
|
31 |
|
|
32 |
public String getNote() { |
|
33 |
return note; |
|
34 |
} |
|
35 |
|
|
36 |
public int getValue() { |
|
37 |
return value; |
|
38 |
} |
|
39 |
|
|
40 |
EM_SHOW_COLOR(int givenValue, String note) { |
|
41 |
this.value = givenValue; |
|
42 |
this.note = note; |
|
43 |
} |
|
44 |
|
|
45 |
public static String getNoteByValue(int givenValue) { |
|
46 |
for (EM_SHOW_COLOR enumType : EM_SHOW_COLOR.values()) { |
|
47 |
if (givenValue == enumType.getValue()) { |
|
48 |
return enumType.getNote(); |
|
49 |
} |
|
50 |
} |
|
51 |
return null; |
|
52 |
} |
|
53 |
|
|
54 |
public static int getValueByNote(String givenNote) { |
|
55 |
for (EM_SHOW_COLOR enumType : EM_SHOW_COLOR.values()) { |
|
56 |
if (givenNote.equals(enumType.getNote())) { |
|
57 |
return enumType.getValue(); |
|
58 |
} |
|
59 |
} |
|
60 |
return -1; |
|
61 |
} |
|
62 |
|
|
63 |
public static EM_SHOW_COLOR getEnum(int value) { |
|
64 |
for (EM_SHOW_COLOR e : EM_SHOW_COLOR.values()) { |
|
65 |
if (e.getValue() == value) |
|
66 |
return e; |
|
67 |
} |
|
68 |
return EM_SHOW_COLOR.EM_SHOW_COLOR_UNKNOWN; |
|
69 |
} |
|
70 |
|
|
71 |
} |