提交 | 用户 | 时间
|
149dd0
|
1 |
package com.iailab.netsdk.lib.enumeration; |
H |
2 |
|
|
3 |
/** |
|
4 |
* 温度单位 |
|
5 |
* |
|
6 |
* @author 47040 |
|
7 |
* @version 1.0.0 |
|
8 |
* @since Created in 2021/3/8 20:45 |
|
9 |
*/ |
|
10 |
public enum EM_TEMPERATURE_UNIT_EX { |
|
11 |
|
|
12 |
/** |
|
13 |
* 未知 |
|
14 |
*/ |
|
15 |
EM_TEMPERATURE_EX_UNKNOWN(0, "未知"), |
|
16 |
/** |
|
17 |
* 摄氏度 |
|
18 |
*/ |
|
19 |
EM_TEMPERATURE_EX_CENTIGRADE(1, "摄氏度"), |
|
20 |
/** |
|
21 |
* 华氏度 |
|
22 |
*/ |
|
23 |
EM_TEMPERATURE_EX_FAHRENHEIT(2, "华氏度"), |
|
24 |
/** |
|
25 |
* 开尔文 |
|
26 |
*/ |
|
27 |
EM_TEMPERATURE_EX_KELVIN(3, "开尔文"); |
|
28 |
|
|
29 |
private final int value; |
|
30 |
private final String note; |
|
31 |
|
|
32 |
EM_TEMPERATURE_UNIT_EX(int givenValue, String note) { |
|
33 |
this.value = givenValue; |
|
34 |
this.note = note; |
|
35 |
} |
|
36 |
|
|
37 |
public String getNote() { |
|
38 |
return note; |
|
39 |
} |
|
40 |
|
|
41 |
public int getValue() { |
|
42 |
return value; |
|
43 |
} |
|
44 |
|
|
45 |
public static String getNoteByValue(int givenValue) { |
|
46 |
for (EM_TEMPERATURE_UNIT_EX enumType : EM_TEMPERATURE_UNIT_EX.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_TEMPERATURE_UNIT_EX enumType : EM_TEMPERATURE_UNIT_EX.values()) { |
|
56 |
if (givenNote.equals(enumType.getNote())) { |
|
57 |
return enumType.getValue(); |
|
58 |
} |
|
59 |
} |
|
60 |
return -1; |
|
61 |
} |
|
62 |
|
|
63 |
public static EM_TEMPERATURE_UNIT_EX getEnum(int value) { |
|
64 |
for (EM_TEMPERATURE_UNIT_EX e : EM_TEMPERATURE_UNIT_EX.values()) { |
|
65 |
if (e.getValue() == value) |
|
66 |
return e; |
|
67 |
} |
|
68 |
return EM_TEMPERATURE_UNIT_EX.EM_TEMPERATURE_EX_UNKNOWN; |
|
69 |
} |
|
70 |
|
|
71 |
} |