VehicleEnum.java
976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.dituhui.pea.enums;
import cn.hutool.core.util.ObjectUtil;
import java.util.Objects;
/**
* 交通工具:1汽车;2电动车;3自行车;4步行 默认是汽车
*
* @author RenPing
* @date 2023/10/24
*/
public enum VehicleEnum {
CAR(1, "驾车"),
ELECTRIC_CAR(2, "电动车"),
BICYCLE(3, "骑行"),
WALK(4, "步行");
private Integer code;
private String name;
private VehicleEnum(Integer code, String name) {
this.code = code;
this.name = name;
}
public Integer getCode() {
return code;
}
public String getName() {
return name;
}
public static String getNameByValue(Integer value) {
if (Objects.isNull(value)) {
return null;
}
for (VehicleEnum enums : VehicleEnum.values()) {
if (ObjectUtil.equal(enums.getCode(), value)) {
return enums.getName();
}
}
return null;
}
}