枚举
package com.enums;
public class Status {
/**
* 删除状态
* @author qingtian
*
*/
public static enum CommonStatus{
DELETE(0,"删除"),
NORMAL(1,"正常");
public Integer value;
public String name;
private CommonStatus(Integer value, String name) {
this.value = value;
this.name = name;
}
}
/**
* 删除状态
* @author qingtian
*
*/
public static enum FileOnloadStatus{
PENDINGPOLLING(0,"待轮询"),
SUCCESS(1,"处理完成"),
ERROR(2,"处理失败"),
INHAND(3,"处理中");
public Integer value;
public String name;
private FileOnloadStatus(Integer value, String name) {
this.value = value;
this.name = name;
}
}
/**
* 启用禁用状态
* @author qingtian
*
*/
public static enum EnableStatus{
ENABLE(1,"启用"),
DISABLE(0,"禁用");
public Integer value;
public String name;
private EnableStatus(Integer value, String name) {
this.value = value;
this.name = name;
}
}
/**
* 初始化状态
* @author qingtian
*/
public static enum InitializeStatus{
DELETED(-1,"已删除"),
INITIALIZE(1,"初始化"),
UNINITIALIZED(0,"未初始化");
public Integer value;
public String name;
private InitializeStatus(Integer value, String name) {
this.value = value;
this.name = name;
}
}
/**
* 生产类型状态
* @author qingtian
*/
public static enum PlanStatus{
NEWBUILT(1,"新建"),
PRODUCTION(2,"生产中"),
ENDPRODUCTION(3,"生产结束");
public Integer value;
public String name;
private PlanStatus(Integer value, String name) {
this.value = value;
this.name = name;
}
}
}
//具体使用直接调就可以了
(CommonStatus.NORMAL.value)
- 我一般用它来判断状态,比如状态的修改,是否删除,启用禁用这方面
- 并且自定义name和value,完成对条件状态的判断