首页 > 其他 > 详细

枚举在开发中的应用

时间:2016-08-23 16:41:17      阅读:134      评论:0      收藏:0      [点我收藏+]
public enum AttachmentType {

    account("人员"),monitorEnv("设施环境评测评价"),monitorUse("临床使用效果评价"),monitorSafe("质量安全检测评价"),
    equipment("设备合同文件");


    private String description;

    AttachmentType(String description) {
        this.description = description;
    }

    public String getDescription() {
        return description;
    }

    public static AttachmentType getAttechmentTypeByDesc(String desc) {
        if (!StringUtil.hasText(desc))
            return null;
        for (AttachmentType t : values()) {
            if (t.getDescription().equals(desc))
                return t;
        }
        return null;
    }

    public static String getCnName(String enName) {//得到汉语名称
        if (!StringUtil.hasText(enName))
            return "";
        for (AttachmentType e : values()) {
            if (enName.equals(e.name()))
                return e.getDescription();
        }
        return "";
    }
}

 

枚举在开发中的应用

原文:http://www.cnblogs.com/blog411032/p/5799619.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!