content: package org.example.jfranalyzerbackend.config;
  
  import java.util.Objects;
  
  public class Result<T> {
      private Integer code;
      private String msg;
      private T data;
  
      public Result() {
      }
  
      public Result(Integer code, String msg, T data) {
          this.code = code;
          this.msg = msg;
          this.data = data;
      }
  
      public Integer getCode() {
          return code;
      }
  
      public void setCode(Integer code) {
          this.code = code;
      }
  
      public String getMsg() {
          return msg;
      }
  
      public void setMsg(String msg) {
          this.msg = msg;
      }
  
      public T getData() {
          return data;
      }
  
      public void setData(T data) {
          this.data = data;
      }
  
      @Override
      public boolean equals(Object o) {
          if (this == o) return true;
          if (o == null || getClass() != o.getClass()) return false;
          Result<?> result = (Result<?>) o;
          return Objects.equals(code, result.code) && Objects.equals(msg, result.msg) && Objects.equals(data, result.data);
      }
  
      @Override
      public int hashCode() {
          return Objects.hash(code, msg, data);
      }
  
      @Override
      public String toString() {
          return "Result{" +
                  "code=" + code +
                  ", msg='" + msg + '\'' +
                  ", data=" + data +
                  '}';
      }
  
      public static <T> Result<T> success(T data) {
          Result<T> result = new Result<>();
          result.code = 1;
          result.msg = "success";
          result.data = data;
          return result;
      }
  
      public static Result<Void> success() {
          Result<Void> result = new Result<>();
          result.code = 1;
          result.msg = "success";
          return result;
      }
  
      public static Result<Void> error(String msg) {
          Result<Void> result = new Result<>();
          result.code = 0;
          result.msg = msg;
          return result;
      }
  
      /**
       * 泛型错误方法，用于返回指定类型的错误结果
       * @param msg 错误消息
       * @param <T> 数据类型
       * @return 错误结果
       */
      public static <T> Result<T> errorWithType(String msg) {
          Result<T> result = new Result<>();
          result.code = 0;
          result.msg = msg;
          result.data = null;
          return result;
      }
  }
  
  
  