소스 검색

添加工具类

xujiawei 4 년 전
부모
커밋
33e931af18
1개의 변경된 파일93개의 추가작업 그리고 0개의 파일을 삭제
  1. 93 0
      src/main/java/edu/nju/util/TransUtil.java

+ 93 - 0
src/main/java/edu/nju/util/TransUtil.java

@@ -0,0 +1,93 @@
+package edu.nju.util;
+
+/**
+ * @Author JiaWei Xu
+ * @Date 2020-12-25 11:12
+ * @Email xjwhhh233@outlook.com
+ */
+public class TransUtil {
+
+    private static final String UNDETERMINED = "待定";
+    private static final String LIGHTER = "较轻";
+    private static final String NORMAL = "一般";
+    private static final String SERIOUS = "严重";
+    private static final String URGENT = "紧急";
+    private static final String OTHER = "其他";
+    private static final String IRREGULAR = "无规律";
+    private static final String SMALL_PROBABILITY = "小概率复现";
+    private static final String BIG_PROBABILITY = "大概率复现";
+    private static final String CERTAIN = "必现";
+
+
+    public int severityTransFromString(String str) {
+        if (UNDETERMINED.equals(str)) {
+            return 1;
+        }
+        if (LIGHTER.equals(str)) {
+            return 2;
+        }
+        if (NORMAL.equals(str)) {
+            return 3;
+        }
+        if (SERIOUS.equals(str)) {
+            return 4;
+        }
+        if (URGENT.equals(str)) {
+            return 5;
+        }
+        return 0;
+    }
+
+    public int recurrentTransFromString(String str) {
+        if (OTHER.equals(str)) {
+            return 1;
+        }
+        if (IRREGULAR.equals(str)) {
+            return 2;
+        }
+        if (SMALL_PROBABILITY.equals(str)) {
+            return 3;
+        }
+        if (BIG_PROBABILITY.equals(str)) {
+            return 4;
+        }
+        if (CERTAIN.equals(str)) {
+            return 5;
+        }
+        return 0;
+    }
+
+    public String severityTransFromInt(int num) {
+        switch (num) {
+            case 1:
+                return UNDETERMINED;
+            case 2:
+                return LIGHTER;
+            case 3:
+                return NORMAL;
+            case 4:
+                return SERIOUS;
+            case 5:
+                return URGENT;
+            default:
+                return "";
+        }
+    }
+
+    public String recurrentTransFromInt(int num) {
+        switch (num) {
+            case 1:
+                return OTHER;
+            case 2:
+                return IRREGULAR;
+            case 3:
+                return SMALL_PROBABILITY;
+            case 4:
+                return BIG_PROBABILITY;
+            case 5:
+                return CERTAIN;
+            default:
+                return "";
+        }
+    }
+}