00-XxEnum

pom.xml

1
2
3
4
5
6
7
8
9
10
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.16</version>
</dependency>
<dependency>
<groupId>com.google.code.google-collections</groupId>
<artifactId>google-collect</artifactId>
<version>snapshot-20080530</version>
</dependency>

XxEnum.java

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
public class XxEnum {

/**
* 返回结果状态码
*/
@Getter
@AllArgsConstructor
public enum XxResult {
/** */
R_400("400", "系统繁忙,请稍后再试"),
;

private final String code;
private final String name;
}

/**
* 功能类型
*/
@Getter
@AllArgsConstructor
public enum XxType {
/** */
CLIQUE("C", "拼团"),
;

private final String code;
private final String name;

public static XxType getByCode(String code) {
if (code != null && code.length() > 0) {
for (XxType xxType : XxType.values()) {
if (code.equals(xxType.getCode())) {
return xxType;
}
}
}
return null;
}

public static String[] getCodes() {
List<String> codes = Lists.newArrayList(XxType.class.getEnumConstants()).stream().map(e -> e.getCode()).collect(Collectors.toList());
return Arrays.copyOf(codes.toArray(), codes.size(), String[].class);
}
}
}

00-XxEnum
https://janycode.github.io/2021/03/14/20_收藏整理/03_工具类/00-XxEnum/
作者
Jerry(姜源)
发布于
2021年3月14日
许可协议