提交 | 用户 | 时间
|
149dd0
|
1 |
package com.iailab.netsdk.lib.enumeration; |
H |
2 |
|
|
3 |
|
|
4 |
/** |
|
5 |
* @author 291189 |
|
6 |
* @description 供电类型 |
|
7 |
* @date 2022/09/01 15:11:24 |
|
8 |
*/ |
|
9 |
public enum NET_EM_POWER_TYPE { |
|
10 |
/** |
|
11 |
未知 |
|
12 |
*/ |
|
13 |
NET_EM_POWER_TYPE_UNKNOWN(-1,"未知"), |
|
14 |
/** |
|
15 |
电源适配器 |
|
16 |
*/ |
|
17 |
NET_EM_POWER_TYPE_POWERADAPTER(0,"电源适配器"), |
|
18 |
/** |
|
19 |
电池 |
|
20 |
*/ |
|
21 |
NET_EM_POWER_TYPE_BATTERY(1,"电池"), |
|
22 |
/** |
|
23 |
电池+电源适配器 |
|
24 |
*/ |
|
25 |
NET_EM_POWER_TYPE_BATTERY_AND_POWERADAPTER(2,"电池+电源适配器"); |
|
26 |
|
|
27 |
private int value; |
|
28 |
|
|
29 |
private String note; |
|
30 |
|
|
31 |
public String getNote() { |
|
32 |
return note; |
|
33 |
} |
|
34 |
|
|
35 |
public int getValue() { |
|
36 |
return value; |
|
37 |
} |
|
38 |
|
|
39 |
NET_EM_POWER_TYPE(int givenValue, String note) { |
|
40 |
this.value = givenValue; |
|
41 |
this.note = note; |
|
42 |
} |
|
43 |
|
|
44 |
public static String getNoteByValue(int givenValue) { |
|
45 |
for (NET_EM_POWER_TYPE enumType : NET_EM_POWER_TYPE.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_EM_POWER_TYPE enumType : NET_EM_POWER_TYPE.values()) { |
|
55 |
if (givenNote.equals(enumType.getNote())) { |
|
56 |
return enumType.getValue(); |
|
57 |
} |
|
58 |
} |
|
59 |
return -2; |
|
60 |
} |
|
61 |
|
|
62 |
public static NET_EM_POWER_TYPE getEnum(int value) { |
|
63 |
for (NET_EM_POWER_TYPE e : NET_EM_POWER_TYPE.values()) { |
|
64 |
if (e.getValue() == value) |
|
65 |
return e; |
|
66 |
} |
|
67 |
return NET_EM_POWER_TYPE.NET_EM_POWER_TYPE_UNKNOWN; |
|
68 |
} |
|
69 |
|
|
70 |
} |