static Enum valueOf(Class enumClass,String name)//返回指定名字,给定类的枚举常量
String toString()//返回枚举常量名
int ordinal()//返回枚举常量在enum声明中的位置,位置为0开始计数
int compareto(E other)//如果枚举常量出现在other之前,则返回一个负值,如果this==other 则返回0,否则返回正值,枚举常量出现的次序在enum声明中给出
Enum.values()// 返回Enum类型枚举List
Reference:
public enum CheckStatusEnum {
FirstPublishStatus("firstPublishStatus",1),
SecondPublishStatus("secondPublishStatus",2),
FixStatus("fixStatus",3);
private String checkContent;
private Integer code;
CheckStatusEnum(String checkContent,Integer code){
this.checkContent=checkContent;
this.code=code;
}
/**
* 根据前端所需查询传输的状态码(checkContent),获得查询码(code)
* */
public static Integer getValue(String checkContent){
for(CheckStatusEnum checkStatusEnum: CheckStatusEnum.values()){
if(checkStatusEnum.getCheckContent().equals(checkContent)){
return checkStatusEnum.getCode();
}
}
return null;
}
public String getCheckContent() {
return checkContent;
}
public void setCheckContent(String checkContent) {
this.checkContent = checkContent;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
}