content: package com.genshin.ojcommon.domain.enums;
  
  import cn.hutool.core.util.StrUtil;
  
  import java.util.Arrays;
  import java.util.List;
  import java.util.stream.Collectors;
  
  /**
   * @author 吴嘉豪
   * @date 2024/1/12 9:16
   */
  public enum JudgeInfoMessageEnum {
      ACCEPTED("Accepted", "成功"),
      WRONG_ANSWER("Wrong Answer", "答案错误"),
      COMPILE_ERROR("Compile Error", "编译错误"),
      MEMORY_LIMIT_EXCEEDED("", "内存溢出"),
      TIME_LIMIT_EXCEEDED("Time Limit Exceeded", "超时"),
      PRESENTATION_ERROR("Presentation Error", "展示错误"),
      WAITING("Waiting", "等待中"),
      OUTPUT_LIMIT_EXCEEDED("Output Limit Exceeded", "输出溢出"),
      DANGEROUS_OPERATION("Dangerous Operation", "危险操作"),
      RUNTIME_ERROR("Runtime Error", "运行错误"),
      SYSTEM_ERROR("System Error", "系统错误");
  
      private final String text;
  
      private final String value;
  
      JudgeInfoMessageEnum(String text, String value) {
          this.text = text;
          this.value = value;
      }
  
      /**
       * 获取值列表
       *
       * @return
       */
      public static List<String> getValues() {
          return Arrays.stream(values()).map(item -> item.value).collect(Collectors.toList());
      }
  
      /**
       * 根据 value 获取枚举
       *
       * @param value
       * @return
       */
      public static JudgeInfoMessageEnum getEnumByValue(String value) {
          // 判断是否为空
          if (StrUtil.isBlank(value)) {
              return null;
          }
          for (JudgeInfoMessageEnum anEnum : JudgeInfoMessageEnum.values()) {
              if (anEnum.value.equals(value)) {
                  return anEnum;
              }
          }
          return null;
      }
  
      public String getValue() {
          return value;
      }
  
      public String getText() {
          return text;
      }
  }
  