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
package com.vci.web.enumpck;
 
import com.vci.starter.web.enumpck.BaseEnum;
 
/**
 * UI布局的区域
 * @author weidy
 * @date 2021-2-15
 */
public enum UILayoutAreaTypeEnum implements BaseEnum {
    /**
     * 西区/导航区
     */
    WEST("west","西区/导航区"),
 
    /**
     * 北区
     */
    NORTH("north","北区/控制区"),
 
    /**
     * 中心区
     */
    CENTER("center","中心区/操作区"),
 
    /**
     * 南区
     */
    SOUTH("south","南区");
 
    /**
     * 值
     */
    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 UILayoutAreaTypeEnum(String value,String text){
        this.value = value;
        this.text = text;
    }
 
    /**
     * 根据名称获取对应的枚举值
     * @param text 名称
     * @return 枚举值
     */
    public static String getValueByText(String text){
        for(UILayoutAreaTypeEnum wenum : UILayoutAreaTypeEnum.values()){
            if(wenum.getText().equalsIgnoreCase(text)){
                return wenum.getValue();
            }
        }
        return "";
    }
 
    /**
     * 根据枚举值获取名称
     * @param value 枚举值
     * @return 名称
     */
    public static String getTextByValue(String value){
        for(UILayoutAreaTypeEnum wenum : UILayoutAreaTypeEnum.values()){
            if(wenum.getValue().equalsIgnoreCase(value)){
                return wenum.getText();
            }
        }
        return "";
    }
 
    /**
     * 值转换为枚举对象
     * @param value 值
     * @return 如果不符合要求返回Null
     */
    public static UILayoutAreaTypeEnum forValue(String value){
        for(UILayoutAreaTypeEnum wenum : UILayoutAreaTypeEnum.values()){
            if(wenum.getValue().equalsIgnoreCase(value)){
                return wenum;
            }
        }
        return UILayoutAreaTypeEnum.CENTER;
    }
}