我比较偏向于这样定义枚举类型。
/**
* 下载服务器ip变化状态枚举
* Created by elle on 2019/2/19.
*/
public enum DownloadSerIpChangeStatus {
IGNORE("ignore", "忽略"), CHANGED("changed", "已改变"), ERROR("error", "错误");
private String code;
private String value;
DownloadSerIpChangeStatus(String code, String value) {
this.code = code;
this.value = value;
}
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 static void main(String[] args) {
System.out.println(DownloadSerIpChangeStatus.CHANGED.getCode() + " " + DownloadSerIpChangeStatus.CHANGED.getValue());
}
}