提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.framework.common.enums; |
H |
2 |
|
|
3 |
import cn.hutool.core.util.ObjUtil; |
|
4 |
import com.iailab.framework.common.core.IntArrayValuable; |
|
5 |
import lombok.AllArgsConstructor; |
|
6 |
import lombok.Getter; |
|
7 |
|
|
8 |
import java.util.Arrays; |
|
9 |
|
|
10 |
/** |
|
11 |
* 通用状态枚举 |
|
12 |
* |
|
13 |
* @author iailab |
|
14 |
*/ |
|
15 |
@Getter |
|
16 |
@AllArgsConstructor |
|
17 |
public enum CommonStatusEnum implements IntArrayValuable { |
|
18 |
|
|
19 |
ENABLE(0, "开启"), |
|
20 |
DISABLE(1, "关闭"); |
|
21 |
|
|
22 |
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CommonStatusEnum::getStatus).toArray(); |
|
23 |
|
|
24 |
/** |
|
25 |
* 状态值 |
|
26 |
*/ |
|
27 |
private final Integer status; |
|
28 |
/** |
|
29 |
* 状态名 |
|
30 |
*/ |
|
31 |
private final String name; |
|
32 |
|
|
33 |
@Override |
|
34 |
public int[] array() { |
|
35 |
return ARRAYS; |
|
36 |
} |
|
37 |
|
|
38 |
public static boolean isEnable(Integer status) { |
|
39 |
return ObjUtil.equal(ENABLE.status, status); |
|
40 |
} |
|
41 |
|
|
42 |
public static boolean isDisable(Integer status) { |
|
43 |
return ObjUtil.equal(DISABLE.status, status); |
|
44 |
} |
|
45 |
|
|
46 |
} |