Java tutorial
/* * Copyright 2011-2016 ZuoBian.com All right reserved. This software is the confidential and proprietary information of * ZuoBian.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only * in accordance with the terms of the license agreement you entered into with ZuoBian.com. */ package com.mmj.app.biz.cons; import org.apache.commons.lang.StringUtils; /** * subject Id(newssubjectId=1;scoffsubjectId=2; pic?subjectId=4; tecsubjectId=100; asksubjectId=151) * * @author zxc Dec 1, 2014 1:38:25 PM */ public enum SubjectEnum { /** * */ ALL(0, "all", ""), /** * */ NEWS(1, "news", ""), /** * */ SCOFF(2, "scoff", ""), /** * ?? */ PIC(4, "pic", "?"), /** * */ TEC(100, "tec", ""), /** * */ ASK(151, "ask", "?"); private int value; private String name; private String desc; private SubjectEnum(int value, String name, String desc) { this.value = value; this.name = name; this.desc = desc; } public String getDesc() { return desc; } public int getValue() { return value; } public String getName() { return name; } /** * ?name? */ public static SubjectEnum getEnum(String name) { if (StringUtils.isEmpty(name)) { return null; } for (SubjectEnum current : values()) { if (StringUtils.equalsIgnoreCase(current.name, name)) { return current; } } return null; } /** * ?value? */ public static SubjectEnum getEnum(Integer value) { if (value == null) { return null; } for (SubjectEnum current : values()) { if (current.value == value) { return current; } } return null; } }