dangsn
2024-06-06 33321f5486fd586fda6fd3f46b7e71754fede28b
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package com.vci.starter.web.enumpck;
 
 
/**
 * 任务调整类型
 * @author weidy
 * @date 2019/10/10 4:23 PM
 */
public  enum VciTaskBusTypeEnum {
    /**
     * 添加
     */
    ADD,
    /**
     * 修改
     */
    EDIT,
    /**
     * 删除
     */
    DELETE,
    /**
     * 冻结
     */
    FREEZE,
    /**
     * 恢复
     */
    RECOVER,
    /**
     * 完成
     */
    FINISH,
    /**
     * 分解
     */
    RESOLVE,
    /**
     * 全部
     */
    ALL;
 
    /**
     * 根据名称获取对应的枚举值
     * @param text 名称
     * @return 枚举值
     */
    public static String getValueByText(String text){
        if(text == null || text.trim().length() == 0){
            return "";
        }else{
            if("删除".equalsIgnoreCase(text)){
                return DELETE.name();
            }else if("修改".equalsIgnoreCase(text)){
                return EDIT.name();
            }else if("冻结".equalsIgnoreCase(text)){
                return FREEZE.name();
            }else if("恢复".equalsIgnoreCase(text)){
                return RECOVER.name();
            }else if("完成".equalsIgnoreCase(text)){
                return FINISH.name();
            }else if("分解".equalsIgnoreCase(text)){
                return RESOLVE.name();
            }else if("全部".equalsIgnoreCase(text)){
                return ALL.name();
            }else{
                return ADD.name();
            }
        }
    }
 
    /**
     * 根据枚举值获取名称
     * @param value 枚举值
     * @return 名称
     */
    public static String getTextByValue(String value){
        VciTaskBusTypeEnum wenum = forValue(value);
        if(wenum == null){
            return  "";
        }
        switch (wenum){
            case DELETE:
                return "删除";
            case EDIT:
                return "修改";
            case FREEZE:
                return "冻结";
            case RECOVER:
                return "恢复";
            case FINISH:
                return "完成";
            case RESOLVE:
                return "分解";
            case ALL:
                return "全部";
            default:
                return "添加";
        }
    }
 
    /**
     * 根据枚举值获取枚举对象
     * @param value 枚举值
     * @return 对应的枚举对象,不匹配的时候返回null
     */
    public static VciTaskBusTypeEnum forValue(String value){
        for(VciTaskBusTypeEnum wenum : VciTaskBusTypeEnum.values()){
            if(wenum.name().equalsIgnoreCase(value)){
                return wenum;
            }
        }
        return null;
    }
 
}