OverallRatingEnum.java
1.24 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
package com.gsc4cloud.gsc.vpc.api.enums;
public enum OverallRatingEnum implements BaseEnum<Integer, String>{
/** 1: 优 */
EXCELLENT(1, "优"),
/** 2: 良 */
GOOD(2, "良"),
/** 3: 中 */
AVERAGE(3, "中"),
/** 4: 差 */
POOR(4, "差");
private final int value;
private final String description;
OverallRatingEnum(int value, String description) {
this.value = value;
this.description = description;
}
/**
* 根据数值解析枚举
*/
public static OverallRatingEnum of(Integer value) {
if (value == null) return null;
for (OverallRatingEnum type : values()) {
if (type.value == value) {
return type;
}
}
return null;
}
/**
* 直接获取中文描述
*/
public static String getDescription(Integer value) {
OverallRatingEnum rating = of(value);
return rating != null ? rating.description : "未知评价";
}
// Getters
public int getValue() { return value; }
public String getDescription() { return description; }
@Override
public Integer getCode() {
return 0;
}
@Override
public String getDesc() {
return "";
}
}