public enum ProductStatus {
disagree("disagree","不同意"),
measurement_agreement("measurement_agreement","测算同意"),
approval("approval","审批中"),
to_be_activation("to_be_activation","待激活"),
to_be_effective("to_be_effective","待启用"),
valid("valid","有效"),
invalid("invalid","无效"),
cancel("cancel","已作废");
public String name;
public String value;
ProductStatus(String name, String value){
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
private static Map<String, String> statusMap = new HashMap<>();
static {
statusMap.put(ProductStatus.valid.getName(), ProductStatus.valid.getValue());
statusMap.put(ProductStatus.to_be_effective.getName(),to_be_effective.getValue());
}
public static String getProductStatusValue(String code){
return statusMap.get(code);
}
}
调用:
ProductStatus.getProductStatusValue(valid);
获取枚举类所有值的骚操作static
最新推荐文章于 2024-05-13 12:19:30 发布