CarUseTypeEnum.java
1.5 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package cn.fw.valhalla.sdk.enums;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;
/**
* 车辆使用性质
*
* @author kurisu
*/
public enum CarUseTypeEnum implements IEnum<Integer> {
/**
* 个人
*/
NO_OPERATING(1, "非运营"),
/**
* 企业单位
*/
OPERATING(2, "运营");
/**
* 值
*/
private final Integer value;
/**
* 名称
*/
@Getter
private final String name;
CarUseTypeEnum(final Integer value, final String name) {
this.value = value;
this.name = name;
}
/**
* 根据枚举值获取枚举对象
*/
@JsonCreator
public static CarUseTypeEnum ofValue(final Integer value) {
for (final CarUseTypeEnum typeEnum : CarUseTypeEnum.values()) {
if (typeEnum.value.equals(value)) {
return typeEnum;
}
}
return null;
}
/**
* 根据枚举中文名字获取枚举对象
*
* @param name 名字
* @return 枚举对象
*/
public static CarUseTypeEnum ofName(final String name) {
for (final CarUseTypeEnum typeEnum : CarUseTypeEnum.values()) {
if (typeEnum.value.equals(name)) {
return typeEnum;
}
}
return null;
}
@Override
@JsonValue
public Integer getValue() {
return value;
}
}