提交 | 用户 | 时间
|
149dd0
|
1 |
package com.iailab.netsdk.lib.enumeration; |
H |
2 |
|
|
3 |
/** |
|
4 |
* 信号灯指示状态 |
|
5 |
* |
|
6 |
* @author : 47040 |
|
7 |
* @since : Created in 2020/8/29 17:02 |
|
8 |
*/ |
|
9 |
public enum NET_TRAFFIC_LIGHT_STATUS { |
|
10 |
|
|
11 |
/** |
|
12 |
* 未知 |
|
13 |
*/ |
|
14 |
LIGHT_STATUS_UNKNOWN(0, "未知"), |
|
15 |
/** |
|
16 |
* 红灯 |
|
17 |
*/ |
|
18 |
LIGHT_STATUS_RED(1, "红灯"), |
|
19 |
/** |
|
20 |
* 绿灯 |
|
21 |
*/ |
|
22 |
LIGHT_STATUS_GREEN(2, "绿灯"), |
|
23 |
/** |
|
24 |
* 黄灯 |
|
25 |
*/ |
|
26 |
LIGHT_STATUS_YELLOW(3, "黄灯"); |
|
27 |
|
|
28 |
private int value; |
|
29 |
private String note; |
|
30 |
|
|
31 |
NET_TRAFFIC_LIGHT_STATUS(int givenValue, String note) { |
|
32 |
this.value = givenValue; |
|
33 |
this.note = note; |
|
34 |
} |
|
35 |
|
|
36 |
public String getNote() { |
|
37 |
return note; |
|
38 |
} |
|
39 |
|
|
40 |
public int getValue() { |
|
41 |
return value; |
|
42 |
} |
|
43 |
|
|
44 |
public static String getNoteByValue(int givenValue) { |
|
45 |
for (NET_TRAFFIC_LIGHT_STATUS enumType : NET_TRAFFIC_LIGHT_STATUS.values()) { |
|
46 |
if (givenValue == enumType.getValue()) { |
|
47 |
return enumType.getNote(); |
|
48 |
} |
|
49 |
} |
|
50 |
return null; |
|
51 |
} |
|
52 |
|
|
53 |
public static int getValueByNote(String givenNote) { |
|
54 |
for (NET_TRAFFIC_LIGHT_STATUS enumType : NET_TRAFFIC_LIGHT_STATUS.values()) { |
|
55 |
if (givenNote.equals(enumType.getNote())) { |
|
56 |
return enumType.getValue(); |
|
57 |
} |
|
58 |
} |
|
59 |
return -1; |
|
60 |
} |
|
61 |
} |