package com.goafanti.common.enums; import java.util.HashMap; import java.util.Map; public enum NewsCacheKey { NEWS_LIST_CACHE_KEY("news_list_cache_key", "策源地新闻列表缓存"), NEWS_PORTAL_LIST_CACHE_KEY("news_portal_list_cache_key", "新闻列表页面缓存"), NEWS_INDEX_LIST_CACHE_KEY("news_index_list_cache_key", "首页新闻列表缓存"), OTHER("", "未知参数"); private String code; private String desc; private static Map status = new HashMap(); private NewsCacheKey(String code, String desc) { this.code = code; this.desc = desc; } static { for (NewsCacheKey value : NewsCacheKey.values()) { status.put(value.getCode(), value); } } public static NewsCacheKey getField(String code) { if (containsType(code)) { return status.get(code); } return OTHER; } public static String getFieldDesc(String code) { return getField(code).getDesc(); } public static boolean containsType(String code) { return status.containsKey(code); } public String getCode() { return code; } public String getDesc() { return desc; } }