package com.ycwl.basic.enums; import java.util.HashMap; import java.util.Map; public enum StatisticEnum { SCAN_THE_CODE_TO_ENTER(0,"扫码进入"), UPLOAD_FACE(1,"上传人脸"), PREVIEWING_VIDEO(2,"预览视频"), POST_PAYMENT(3,"事后支付"), ON_SITE_PAYMENT(4,"现场支付"), REFUND(5,"退款"), MESSAGE_PUSH(6,"消息推送"), DOWNLOAD(8,"下载"), CLICK_PAY(9,"点击支付"), OTHER_ENTER(10,"其他渠道进入"), SUBMIT_PAYMENT(11,"点击支付"), SCAN_MARKED_CODE(20,"扫描特殊标记码"), ; public static final Map cacheMap; static { cacheMap = new HashMap<>(StatisticEnum.values().length); for (StatisticEnum value : StatisticEnum.values()) { cacheMap.put(value.code, value); } } public static final Map valueMap; static { valueMap = new HashMap<>(StatisticEnum.values().length); for (StatisticEnum value : StatisticEnum.values()) { valueMap.put(value.value, value); } } public final Integer code; private final String value; StatisticEnum(Integer code, String value) { this.code = code; this.value = value; } /** * 获取value值 */ public static String getValue(Integer noticeMethod) { if (noticeMethod == null) { return null; } StatisticEnum statisticEnum = cacheMap.get(noticeMethod); if (statisticEnum == null) { return null; } return statisticEnum.value; } /** * 获取code值 */ public static Integer getCode(String noticeMethod) { if (noticeMethod == null) { return -1; } StatisticEnum statisticEnum = valueMap.get(noticeMethod); if (statisticEnum == null) { return -1; } return statisticEnum.code; } }