码值转换方法01
package cn.daoyuan.bdc.zsgl.enums;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
public enum Flag2 {
TDZFLAG_LOCK("0","已锁定"),
TDZFLAG_LQ("1","已领取"),
TDZFLAG_DY("2","已打印"),
TDZFLAG_ZF("3","已作废");
private String code;
private String flag;
private Flag2(String code, String dyfs) {
this.code = code;
this.flag = flag;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getFlag() {
return flag;
}
public String getFlagName (){
return flag;
}
public void setDyfs(String dyfs) {
this.flag = dyfs;
}
private static final Map<String, Flag2> lookup = new HashMap<String, Flag2>();
private static final Map<String, Flag2> nameLookUp = new HashMap<String, Flag2>();
public static final Map<String, String> resMap = new HashMap<String, String>();
static {
for (Flag2 s : EnumSet.allOf(Flag2.class)) {
lookup.put(s.getCode(), s);
nameLookUp.put(s.getFlag(), s);
resMap.put(s.getCode(), s.getFlagName());
}
}
public static Flag2 parse(int code) {
return lookup.get(Integer.valueOf(code));
}
public static Flag2 parseByCode(String code) {
return lookup.get(code);
}
public static Map<String, String> getResmap() {
return resMap;
}
}