系统做对接,2个系统字典不一致,有时候还有些脏数据,转换时容易出错,有没有办法在遇到脏速度的情况下使用default
/**
* 常住类型
*/
public enum Household {
household_01(1, "户籍"),
household_02(2, "非户籍");
private int index;
private String name;
Household(int index, String name) {
this.index = index;
this.name = name;
}
public int getIndex() {
return index;
}
public String getName() {
return name;
}
private static final Map<Integer, Household> lookup_int = new HashMap<>();
static {
for (Household e : EnumSet.allOf(Household.class)) {
lookup_int.put(e.getIndex(), e);
}
}
public static Household find(int index) {
Household value = lookup_int.get(index);
if (value == null) {
return null;
}
return value;
}
}