package com.goafanti.common.enums; import java.util.HashMap; import java.util.Map; import org.apache.commons.lang3.StringUtils; public enum AchievementMaturity { RESEARCH(0, "正在研发"), SAMPLE(1,"已有样品"), PRIMARYTEST(2,"通过小试"), INTERMEDIATETEST(3, "通过中试"), MASSPRODUCTION(4, "可以量产"), OTHER(5, "其他"); private AchievementMaturity(Integer code, String desc) { this.code = code; this.desc = desc; } private static Map status = new HashMap(); static { for (AchievementMaturity value : AchievementMaturity.values()) { status.put(value.getCode(), value); } } public static AchievementMaturity getStatus(Integer code) { if (containsType(code)) { return status.get(code); } return OTHER; } public static AchievementMaturity getStatus(String code) { if (StringUtils.isNumeric(code)) { return getStatus(Integer.parseInt(code)); } return OTHER; } public static boolean containsType(Integer code) { return status.containsKey(code); } private Integer code; private String desc; public Integer getCode() { return code; } public String getDesc() { return desc; } }