/**
* 场景权限-设备-地点
*/
public enum EquipmentScodeEnum {
SHANGHAI("SH",1), NANTONG("NT",2);
/**
* Scode加密前缀
*/
private String prefix;
/**
* 公司代号: 1 上海 2南通
*/
private int companyId;
private EquipmentScodeEnum(String prefix, int companyId) {
this.prefix = prefix;
this.companyId = companyId;
}
// 补充普通方法
public static String getPrefix(int companyId) {
for (EquipmentScodeEnum c : EquipmentScodeEnum.values()) {
if (c.getCompanyId() == companyId) {
return c.prefix;
}
}
return null;
}
public static int getCompanyId(String prefix) {
for (EquipmentScodeEnum ele : values()) {
if(ele.getPrefix().equals(prefix)) return ele.getCompanyId();
}
return 0;
}
// get set 方法 可以使得枚举类具有常量类的那般玩法
public String getPrefix() {
return prefix;
}
public void setPrefix(String prefix) {
this.prefix = prefix;
}
public int getCompanyId() {
return companyId;
}
public void setCompanyId(int companyId) {
this.companyId = companyId;
}
}
枚举类与内部类结合运用,使封装、高内聚更上一层楼
/**
* @Author
* @Description 审批单类型
* Date on 2020/6/27 8:47
*/
public class ExamineType{
//搞点内部类
public enum Prop{
SH("审核",1), ZS("转审",2);
private String propName;
private int propValue;
private Prop(String propName, int propValue) {
this.propName = propName;
this.propValue = propValue;
}
// 补充普通方法
public static String getPropName(int propValue) {
for (Prop c : Prop.values()) {
if (c.getPropValue() == propValue) {
return c.propName;
}
}
return null;
}
public static int getPropValue(String propName) {
for (Prop ele : values()) {
if(ele.getPropName().equals(propName)) return ele.getPropValue();
}
return 0;
}
public String getPropName() {
return propName;
}
public void setPropName(String propName) {
this.propName = propName;
}
public int getPropValue() {
return propValue;
}
public void setPropValue(int propValue) {
this.propValue = propValue;
}
}
public enum TableType{
// 审批表类型 10.邀请制待审核的审批;20:已签到入场审批;30:修改人脸审批;40:访问时间修改审批;
YQDSH("邀请制待审核的审批",10),
YQDRC("已签到入场审批",20),
XGRL("修改人脸审批",30),
FWSJ("访问时间修改审批",40);
private String typeName;
private int typeValue;
TableType(String typeName, int typeValue) {
this.typeName = typeName;
this.typeValue = typeValue;
}
// 补充普通方法
public static String getTypeName(int typeValue) {
for (TableType c : TableType.values()) {
if (c.getTypeValue() == typeValue) {
return c.getTypeName();
}
}
return null;
}
public static int getTypeValue(String typeName) {
for (TableType ele : values()) {
if(ele.getTypeName().equals(typeName)) return ele.getTypeValue();
}
return 0;
}
public String getTypeName() {
return typeName;
}
public void setTypeName(String typeName) {
this.typeName = typeName;
}
public int getTypeValue() {
return typeValue;
}
public void setTypeValue(int typeValue) {
this.typeValue = typeValue;
}
}
}