一、枚举类
package com.xxx.xf.common.enums;import com.xxx.xf.workday.contant.HolidayContant;/*** @Author: wangmq* @Version: 1.0* 操作枚举类*/ public enum XfOperateEnum {// 定义多个由构造方法组成的对象,逗号隔开分号为结束XF_OPERATE_SL("SL","受理", 3, HolidayContant.NATURAL_DAY),XF_OPERATE_BL("BL","办理", 3, HolidayContant.WORKING_DAY),XF_OPERATE_BJ("BJ","办结", 60, HolidayContant.NATURAL_DAY);// 该枚举类构造方法所用的属性// 标识codeprivate String code;// 该操作名称private String value;// 时限天数private int amount;// 时限类别,工作日和自然日private String amountType;// 通过code属性获取对应的枚举对象// XfOperateEnum.values() 返回值是所有枚举类对象public static XfOperateEnum getXfOperateEnumByCode(String code){for(XfOperateEnum xfOperateEnum : XfOperateEnum.values()){if(xfOperateEnum.code.equalsIgnoreCase(code)){return xfOperateEnum;}}return null;}// 该枚举类的全参构造方法XfOperateEnum(String code, String value, int amount, String amountType) {this.code = code;this.value = value;this.amount = amount;this.amountType = amountType;}// 私有属性的set和get方法public String getCode() {return code;}public void setCode(String code) {this.code = code;}public String getValue() {return value;}public void setValue(String value) {this.value = value;}public int getAmount() {return amount;}public void setAmount(int amount) {this.amount = amount;}public String getAmountType() {return amountType;}public void setAmountType(String amountType) {this.amountType = amountType;}}
二、枚举类使用
// 获取该枚举类某个对象的某个属性值 XfOperateEnum.XF_OPERATE_SL.getCode()
// 根据code获取枚举类中对应某个对象 XfOperateEnum operateEnum = XfOperateEnum.getXfOperateEnumByCode(operateType);
dd