枚举类的应用

枚举类的使用=== >展示到页面

0. 创建需要的枚举类  1.赋值

public enum ResumePeopleSizeEnum {
/*公司人数 0:不限 1:1~99 2:100~500 3:500~1000 4:1000~5000 5:5000以上*/
UNLIMITED(0,"不限"),
ONE(1,"0~99"),
TWO(2,"100~500"),
THREE(3,"500~1000"),
FOUR(4,"1000~5000"),
FIVE(5,"5000以上")
;
private Integer code;

private String message;

private ResumePeopleSizeEnum(Integer code, String message) {
this.code = code;
this.message = message;
}

public Integer getCode() {
return code;
}

public String getMessage() {
return message;
}
}


将枚举添加到map中

List<Map<String, Object>>  hotCompanyByPage = iSearchService.getHotCompanyByPage(pageNo,pageSize);
for (Map<String, Object> map : hotCompanyByPage) {
int peopleSize =(int) map.get("peoplesize");
switch (peopleSize){
case 0 :
map.put("peopleSize", ResumePeopleSizeEnum.UNLIMITED.getMessage());
break;
case 1 :
map.put("peopleSize", ResumePeopleSizeEnum.ONE.getMessage());
break;
case 2 :
map.put("peopleSize", ResumePeopleSizeEnum.TWO.getMessage());
break;
case 3 :
map.put("peopleSize", ResumePeopleSizeEnum.THREE.getMessage());
break;
case 4 :
map.put("peopleSize", ResumePeopleSizeEnum.FOUR.getMessage());
break;
case 5 :
map.put("peopleSize", ResumePeopleSizeEnum.FIVE.getMessage());
break;
}
}


posted @ 2018-11-23 14:18  春眠不觉笑  阅读(161)  评论(0编辑  收藏  举报