提交 553440c9 authored 作者: liupengfei's avatar liupengfei

--no commit message

上级 62dfe127
package com.zrqx.core.enums.resource;
import java.util.HashMap;
/**
* 销售类型
* @author cxc
* @date 2018年7月13日下午9:26:42
*/
public enum SalsesTypeEnum {
/** 单售*/
STATUS_1(1, "单售"),
/** 已上架*/
STATUS_2(2, "组合销售");
private final Integer code;
private final String name;
private SalsesTypeEnum(Integer code,String name){
this.code=code;
this.name=name;
}
public static SalsesTypeEnum valueOfCode(Integer code) {
if (code != null) {
throw new IllegalArgumentException("Library Status " + code + " is blank");
}
for (SalsesTypeEnum mt : values()) {
if (mt.getCode().equals(code)) {
return mt;
}
}
throw new IllegalArgumentException("Library Status " + code + " is not exist");
}
/**
* 通过ID获取中文名称
* @param code
* @return
*/
public static String getName(Integer code) {
if (code == null) {
return null;
}
for (SalsesTypeEnum mt : values()) {
if (mt.getCode().equals(code)) {
return mt.getName();
}
}
return null;
}
/**
* 获取所有的枚举,以MAP返回
* @return
*/
public static HashMap<Integer,String> getAllEnumMap() {
HashMap<Integer,String> map = new HashMap<Integer,String>();
for (SalsesTypeEnum mt : values()) {
map.put(mt.getCode(), mt.getName());
}
return map;
}
public Integer getCode() {
return code;
}
public String getName() {
return name;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论