Helius
2022-05-24 560228ac3c15cccce0b2a5994d44e4e81b5b3b73
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
package com.matrix.system.enums;
 
import com.google.common.collect.Lists;
import com.matrix.core.enums.EnumApiShowAble;
import com.matrix.core.enums.EnumsShowVo;
import com.matrix.core.exception.GlobleException;
 
import java.util.List;
import java.util.stream.Collectors;
 
/**
 * 是否枚举
 * @author jyy
 */
public enum BooleanEnum implements EnumApiShowAble {
 
    TRUE(1, "是"),
    FALSE(2, "否"),
    DEFAULT(3, ""),
    ;
 
    private Integer value;
 
    private String displayName;
 
    BooleanEnum(Integer value, String displayName) {
        this.value = value;
        this.displayName = displayName;
    }
 
    public static String getByValue(Integer value) {
        for (int i = 0; i < values().length; i++) {
            if (value.equals(values()[i].getValue())) {
                return values()[i].displayName;
            }
        }
        throw new GlobleException("无效枚举值");
    }
 
    @Override
    public String getEnumCode() {
        return "booleanEnum";
    }
 
    @Override
    public List<EnumsShowVo> getEnumsShowVos() {
        return Lists.newArrayList(values()).stream().map(item ->
                EnumsShowVo.builder()
                        .displayName(item.getDisplayName())
                        .value(item.value)
                        .build()
        ).collect(Collectors.toList());
    }
 
    public Integer getValue() {
        return value;
    }
 
    public String getDisplayName() {
        return displayName;
    }
 
}