枚举类型使用的最佳实践
来源:互联网 发布:java中setscale 编辑:程序博客网 时间:2024/06/10 21:53
import org.apache.commons.lang.StringUtils;public enum CertTypeEnum { 身份证(0, "身份证"), 护照(1, "护照"), 军官证(2, "军官证"), 士兵证(3, "士兵证"), 回乡证(4, "回乡证"), 临时身份证(5, "临时身份证"), 户口簿(6, "户口簿"), 警官证(7, "警官证"), 台胞证(8, "台胞证"), 营业执照(9, "营业执照"), 其它证件(10, "其它证件"), ; /** * Getter method for property <tt>code</tt>. * * @return property value of code */ public int getCode() { return code; } /** * Setter method for property <tt>code</tt>. * * @param code value to be assigned to property code */ public void setCode(int code) { this.code = code; } /** * Getter method for property <tt>desc</tt>. * * @return property value of desc */ public String getDesc() { return desc; } /** * Setter method for property <tt>desc</tt>. * * @param desc value to be assigned to property desc */ public void setDesc(String desc) { this.desc = desc; } private CertTypeEnum(int code, String desc) { this.code = code; this.desc = desc; } /** code */ private int code; /** desc */ private String desc; public static CertTypeEnum getByCode(String code) { if (StringUtils.isBlank(code)) { return null; } for (CertTypeEnum item : values()) { //values()是枚举的静态方法 if (StringUtils.equals(String.valueOf(item.getCode()), code)) { return item; } } return null; }}
0 0
- 枚举类型使用的最佳实践
- java枚举最佳实践
- 枚举类型的使用
- 枚举类型的使用
- 枚举类型的使用
- 枚举类型的使用
- 枚举类型的使用
- 枚举类型的使用
- 枚举类型的使用
- 枚举类型的使用
- js判断变量类型的最佳实践
- RecyclerView 多类型Adapter的最佳实践
- 使用Junit的最佳实践
- Java枚举类型的使用
- Java枚举类型的使用
- 使用枚举类型的注意事项
- Java枚举类型的使用
- 枚举类型的简单使用
- 缓存穿透与缓存雪崩
- 【多校10】HDU 5407 5410 5411 5414 5416
- ionic localstorage使用例子
- 实现select自动选择下拉菜单的值
- Flume-ng+Kafka+Storm处理日志
- 枚举类型使用的最佳实践
- POJ 3279 Fliptile
- eclipse到Android Studio的项目迁移
- Eclipse生成的java class文件通过java命令行调用提示Exception in thread "main" java.lang.NoClassDefFoundError
- 启动Tomcat提示:指定的服务未安装
- CF251A. Points on Line
- 5.2 继承体系下的对象构造
- 九度oj 1114
- mysql 修改root密码 admin数据库消失解决方法