创建枚举常用有两种方法
一:直接创建一个枚举类
public enum MailType {
toDoMail("a"),chartMail("b"), reportMail("c");
private String tempAddr;
//创建构造方法
private MailType(String tempAddr) {
this.tempAddr = tempAddr;
}
public String getTempAddr(){
return this.tempAddr;
}
}
该类的使用:MailType.toDoMail.getTempAddr();返回的为a
二:
package com.credithc.workorder.manage.task.entity.caifu;
public class ActivitiParamter{
/**
* 处理状态
* 0:不通过 1:通过
*/
public static final String WO_STATUS="status";
public static enum STATUS {
YES("1", "通过"), NO("0", "不通过");
private String key;
private String value;
//该枚举的构造方法
private STATUS(String key, String value) {
this.key = key;
this.value = value;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
}
该枚举类的使用:ActivitiParamter.WO_STATUS,返回的是status
ActivitiParamter.STATUS .NO.getKey()返回的是“不通过”