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; } }