/**
*cjm
*/
public enum BooleanEnum {
REAL(1, true),//true
FAKE(0, false);//false
private int value;
private Boolean bo;
private BooleanEnum(int value, Boolean bo) {
this.value = value;
this.bo = bo;
}
public static Boolean numberToBo(int value) {
for (BooleanEnum en : BooleanEnum.values()) {
if (en.getValue() == value) {
return en.bo;
}
}
return null;
}
public static Integer boToNumber(Boolean bo) {
for (BooleanEnum en : BooleanEnum.values()) {
if (en.getBo() == bo) {
return en.value;
}
}
return null;
}
public int getValue() {
return value;
}
public Boolean getBo() {
return bo;
}
}
package com.kr.chancedata.enums; import com.google.common.collect.Lists; import org.apache.commons.collections.CollectionUtils; import java.util.*; public enum IndustrySupersetEnum { E_COMMERCE("电商", 1), SOCIAL_NETWORK("社交", 2), INTELLIGENT_HARDWARE("硬件", 5), MEDIA("文娱传媒", 6), SOFTWARE("工具", 7), CONSUMER_LIFESTYLE("消费生活", 8), FINANCE("金融", 9), MEDICAL_HEALTH("医疗健康", 10), SERVICE_INDUSTRIES("企业服务", 11), TRAVEL_OUTDOORS("旅游", 12), PROPERTY_AND_HOME_FURNISHINGS("房产家居", 13), EDUCATION_TRAINING("教育", 15), AUTO("汽车交通", 16), LOGISTICS("物流", 19), AI("人工智能", 21), UAV("无人机", 22), ROBOT("机器人", 23), VR_AR("VR·AR", 24), SPORTS("体育", 25), FARMING("农业", 26), MANUFACTURING("生产制造",20), PEC("光电",27), PUB("公用事业",28), CHEMICAL("化工",29), MINERALS_RESOURCES("能源矿产",30), MATERIALS("材料",31), ENVIRONMENTAL_PROTECTION("环保",32), REAL_ESTATE("地产建筑",38); private String desc; private int value; IndustrySupersetEnum(String desc, int value) { this.desc = desc; this.value = value; } public static List<String> parseDesc(List<Integer> values) { if (CollectionUtils.isNotEmpty(values)) { List<String> ret = Lists.newArrayList(); for (Integer value : values) { for (IndustrySupersetEnum industrySupersetEnum : values()) { if (industrySupersetEnum.getValue() == value) { ret.add(industrySupersetEnum.getDesc()); } } } return ret; } return Collections.emptyList(); } public static IndustrySupersetEnum parse(Integer value) { if (value != null) { for (IndustrySupersetEnum industrySupersetEnum : values()) { if (industrySupersetEnum.getValue() == value) { return industrySupersetEnum; } } } return null; } public static Integer parseIntVal(String desc) { for (IndustrySupersetEnum industrySupersetEnum : values()) { if (industrySupersetEnum.getDesc().equals(desc)) { return industrySupersetEnum.getValue(); } } return null; } public static String parseDesc(Integer value) { IndustrySupersetEnum parse = parse(value); return parse != null ? parse.getDesc() : ""; } public static List<Map<String,Object>> getall(){ final IndustrySupersetEnum[] values = IndustrySupersetEnum.values(); List<Map<String,Object>> all= new ArrayList<>(); for(IndustrySupersetEnum industrySupersetEnum:values){ if (industrySupersetEnum.value==0) continue; HashMap<String, Object> singleHashMap = new HashMap<>(); singleHashMap.put("industryId",industrySupersetEnum.getValue()); singleHashMap.put("industryName",industrySupersetEnum.getDesc()); all.add(singleHashMap); } return all; } public int getValue() { return value; } public String getDesc() { return desc; } }