xiejun
2024-09-09 c826afb6dbc2c1d4433b3c127c5f30f9f72fb2dc
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
package com.vci.web.enumpck;
 
import com.vci.starter.web.enumpck.BaseEnum;
 
/**
 * UI组件的类型
 * @author weidy
 * @date 2021-2-15
 */
public enum UIComponentTypeEnum implements BaseEnum {
    /**
     * 表格
     */
    TABLE("table","表格"),
 
    /**
     * 自定义模板
     */
    CUSTOMER("customer","自定义模板"),
 
    /**
     * 树表
     */
    TREE_GRID("treeGrid","树表"),
 
    /**
     * 表单
     */
    FORM("form","表单"),
 
    /**
     * 树
     */
    TREE("tree","树");
 
    /**
     * 值
     */
    private String value;
 
    /**
     * 显示文本
     */
    private String text;
 
    @Override
    public String getValue() {
        return value;
    }
 
    @Override
    public String getText() {
        return text;
    }
 
    public void setValue(String value) {
        this.value = value;
    }
 
    public void setText(String text) {
        this.text = text;
    }
 
    private UIComponentTypeEnum(String value, String text){
        this.value = value;
        this.text = text;
    }
 
    /**
     * 根据名称获取对应的枚举值
     * @param text 名称
     * @return 枚举值
     */
    public static String getValueByText(String text){
        for(UIComponentTypeEnum wenum : UIComponentTypeEnum.values()){
            if(wenum.getText().equalsIgnoreCase(text)){
                return wenum.getValue();
            }
        }
        return "";
    }
 
    /**
     * 根据枚举值获取名称
     * @param value 枚举值
     * @return 名称
     */
    public static String getTextByValue(String value){
        for(UIComponentTypeEnum wenum : UIComponentTypeEnum.values()){
            if(wenum.getValue().equalsIgnoreCase(value)){
                return wenum.getText();
            }
        }
        return "";
    }
 
    /**
     * 值转换为枚举对象
     * @param value 值
     * @return 如果不符合要求返回Null
     */
    public static UIComponentTypeEnum forValue(String value){
        for(UIComponentTypeEnum wenum : UIComponentTypeEnum.values()){
            if(wenum.getValue().equalsIgnoreCase(value)){
                return wenum;
            }
        }
        return UIComponentTypeEnum.TABLE;
    }
}