zoukankan      html  css  js  c++  java
  • 一个枚举类

    public enum MsgType {
        
        IPCHANGE_MSG(1, "ip地址改变警报"),
        LOCATION_CHANGE_MSG(2,"异地登录警报"),
        KEYWORD_MSG(3, "关键字警报"),
        STATUS_ABNORMAL_MSG(4, "状态异常警报"),
        APPTHRESHOLD_MSG(5, "ip地址改变警报"),
        USERTHRESHOLD_MSG(6, "ip地址改变警报"),
        APPERROE_MSG(7, "ip地址改变警报"),
        USERERROR_MSG(8, "ip地址改变警报");
    
        private Integer type;
        private String desc;
    
        private MsgType(Integer type, String desc) {
            this.type = type;
            this.desc = desc;
        }
    
        public static MsgType getMsgType(Integer code) {
            MsgType status = null;
            switch (code) {
            case 1:
                status = IPCHANGE_MSG;
                break;
            case 2:
                status = LOCATION_CHANGE_MSG;
                break;
            case 3:
                status = KEYWORD_MSG;
                break;
            case 4:
                status = STATUS_ABNORMAL_MSG;
                break;
            case 5:
                status = APPTHRESHOLD_MSG;
                break;
            case 6:
                status = USERTHRESHOLD_MSG;
                break;
            case 7:
                status = APPERROE_MSG;
                break;
            case 8:
                status = USERERROR_MSG;
                break;
            }
            return status;
        }
    
        public static Map<Integer, String> getChoiceMap() {
            HashMap<Integer, String> map = new HashMap<Integer, String>();
            for (MsgType item : MsgType.values()) {
                map.put(item.getType(), item.getDesc());
            }
            return map;
        }
    
        public Integer getType() {
            return type;
        }
    
        public void setType(Integer type) {
            this.type = type;
        }
    
        public String getDesc() {
            return desc;
        }
    
        public void setDesc(String desc) {
            this.desc = desc;
        }
    }
     
  • 相关阅读:
    Scala(四)流程控制
    Scala(九)异常
    Idea中安装翻译插件
    hiveserver2启动卡住问题解决方案
    Scala(十)隐式转换
    Scala(七)集合
    Scala(六)面向对象
    Scala(八)模式匹配
    SharePoint 2010 文档库添加文件icon
    Windows Server 2008 r2 在Hyperv里搭建SharePoint 2010开发环境
  • 原文地址:https://www.cnblogs.com/duan2/p/7485434.html
Copyright © 2011-2022 走看看