Enum
public enum GenderEnum { MAN("1","男"), WOMAN("2","女"); String code; String name; GenderEnum(String code,String name){ this.code = code; this.name = name; } public static String getName(String code){ if (ObjectUtils.isEmpty(code)) { return null; } for (GenderEnum gender : GenderEnum.values()) { if (gender.getCode() == code) { return gender.getName(); } } return null; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } public String getName() { return name; } public void setName(String name) { this.name = name; } }