|
@@ -0,0 +1,63 @@
|
|
|
+package com.diagbot.enums;
|
|
|
+
|
|
|
+import com.diagbot.core.KeyedNamed;
|
|
|
+import lombok.Setter;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description: 是否枚举
|
|
|
+ * @author: gaodm
|
|
|
+ * @time: 2021/3/2 13:42
|
|
|
+ */
|
|
|
+public enum YesNoEnum implements KeyedNamed {
|
|
|
+ No(0, "否"),
|
|
|
+ Yes(1, "是");
|
|
|
+
|
|
|
+ @Setter
|
|
|
+ private int key;
|
|
|
+
|
|
|
+ @Setter
|
|
|
+ private String name;
|
|
|
+
|
|
|
+ YesNoEnum(int key, String name) {
|
|
|
+ this.key = key;
|
|
|
+ this.name = name;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static YesNoEnum getEnum(int key) {
|
|
|
+ for (YesNoEnum item : YesNoEnum.values()) {
|
|
|
+ if (item.key == key) {
|
|
|
+ return item;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static YesNoEnum getEnum(String name) {
|
|
|
+ for (YesNoEnum item : YesNoEnum.values()) {
|
|
|
+ if (item.name.equals(name)) {
|
|
|
+ return item;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String getName(int key) {
|
|
|
+ YesNoEnum item = getEnum(key);
|
|
|
+ return item != null ? item.name : null;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Integer getKey(String name) {
|
|
|
+ YesNoEnum item = getEnum(name);
|
|
|
+ return item != null ? item.key : null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getKey() {
|
|
|
+ return key;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getName() {
|
|
|
+ return name;
|
|
|
+ }
|
|
|
+}
|