package com.vci.client.portal.NewNewUI.buttonmng; import com.vci.common.portal.enums.GetByType; public enum OptMode { View("View", "View", 0), Add("Table", "表格", 1), Update("Update", "Update", 2); private String name = ""; private String label = ""; private int intVal = 1; private OptMode(String name, String label, int intVal){ this.name = name; this.label = label; this.intVal = intVal; } public static OptMode getByName(String name){ OptMode res = getByType(GetByType.Name, name); return res; } public static OptMode getByLabel(String label){ OptMode res = getByType(GetByType.Label, label); return res; } public static OptMode getByIntVal(int intVal){ OptMode res = getByType(GetByType.IntVal, String.valueOf(intVal)); return res; } public static OptMode getByType(GetByType type, String val){ OptMode[] alls = getAll(); OptMode res = null; for(OptMode obj : alls){ if(type == GetByType.Name && obj.getName().equalsIgnoreCase(val)){ res = obj; break; } else if(type == GetByType.Label && obj.getLabel().equalsIgnoreCase(val)){ res = obj; break; } else if(type == GetByType.IntVal && String.valueOf(obj.getIntVal()).equalsIgnoreCase(val)){ res = obj; break; } } return res; } public static OptMode[] getAll(){ return OptMode.values(); } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getLabel() { return label; } public void setLabel(String label) { this.label = label; } public int getIntVal() { return intVal; } public void setIntVal(int intVal) { this.intVal = intVal; } }