| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- /**
- * Copyright
- * All right reserved.
- * 项目名称:
- * 创建日期:2022/3/7
- */
- package org.springblade.enums;
- /***
- * Date:2022/3/7
- * Title:是否枚举类
- * Description:对本文件的详细描述,原则上不能少于30字
- * @author admin
- * @mender:(文件的修改者,文件创建者之外的人)
- * @version 1.0
- * Remark:认为有必要的其他信息
- */
- public enum WhetherEnum {
- /** 否 */
- TYPE_1(1, "否"),
- /** 是 */
- TYPE_2(2, "是");
- private int code;
- private String name;
- private WhetherEnum(int code, String name) {
- this.code = code;
- this.name = name;
- }
- /**
- * Function:根据code来获取对应的name
- * Author: Admin
- * Date:2021/6/26
- * @param code
- * @return java.lang.String
- * @throws Exception
- */
- public static String getName(int code) {
- for (WhetherEnum type : WhetherEnum.values()) {
- if (type.code == code) {
- return type.name;
- }
- }
- return "";
- }
- /**
- * Function:根据code来获取对应的枚举常量
- * Author: Admin
- * Date:2021/6/26
- * @param code
- * @return com.zhgzjg.web.enums.DeleteFlag
- * @throws Exception
- */
- public static WhetherEnum getEnumByCode(int code) {
- for (WhetherEnum type : WhetherEnum.values()) {
- if (type.code == code) {
- return type;
- }
- }
- return null;
- }
- /**
- * Function:根据name来获取对应的枚举常量
- * Author: Admin
- * Date:2021/6/26
- * @param name
- * @return com.zhgzjg.web.enums.DeleteFlag
- * @throws Exception
- */
- public static WhetherEnum getEnumByName(String name) {
- for (WhetherEnum type : WhetherEnum.values()) {
- if (type.name.equals(name)) {
- return type;
- }
- }
- return null;
- }
- public int getCode() {
- return code;
- }
- public void setCode(int code) {
- this.code = code;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- }
|