运用数结构的思想(在数据库中把性别的值设置为 男 1 女 0)
//数据结构思想应用
public static final Integer EMP_GENDER_OF_MAN = 1;
public static final Integer EMP_GENDER_OF_WOMAN = 0;
public static final String EMP_GENDER_OF_MAN_VIEW = "男";
public static final String EMP_GENDER_OF_WOMAN_VIEW = "女";
public static final Map<Integer, String> genderMap = new HashMap<Integer, String>();
static{
genderMap.put(EMP_GENDER_OF_MAN, EMP_GENDER_OF_MAN_VIEW);
genderMap.put(EMP_GENDER_OF_WOMAN, EMP_GENDER_OF_WOMAN_VIEW);
}
//设置值
public void setGender(Integer gender) {
this.gender = gender;
this.genderView = genderMap.get(gender);
}
//获取值
public Integer getGender() {
return gender;
}