Class Result<T>

java.lang.Object
cn.longky.common.model.Result<T>

public class Result<T> extends Object
请求结果
Since:
1.0
Author:
yingzhan
  • Constructor Details

    • Result

      protected Result()
    • Result

      protected Result(boolean success)
  • Method Details

    • withError

      public Result<T> withError(ErrorCode errorCode)
      构造请求错误结果
      Parameters:
      errorCode - 错误码
      Returns:
      请求结果
    • withThrowable

      public Result<T> withThrowable(Throwable throwable)
      构造请求异常结果
      Parameters:
      throwable - 异常信息
      Returns:
      请求结果
    • withError

      public Result<T> withError(String errorCode, String errorMsg)
      构造请求结果
      Parameters:
      errorCode - 错误码
      errorMsg - 错误信息
      Returns:
      请求结果
    • withSuccess

      public Result<T> withSuccess(T result)
      构造请求结果
      Parameters:
      result - 结果数据
      Returns:
      请求结果
    • ofSuccess

      public static <T> Result<T> ofSuccess(T result)
      构造请求结果
      Type Parameters:
      T - 数据类型
      Parameters:
      result - 结果数据
      Returns:
      请求结果
    • ofError

      public static <T> Result<T> ofError(ErrorCode errorCode)
      构造请求结果
      Type Parameters:
      T - 数据类型
      Parameters:
      errorCode - 错误码对象
      Returns:
      请求结果
    • ofError

      public static <T> Result<T> ofError(String errorCode, String errorMsg)
      构造请求结果
      Type Parameters:
      T - 数据类型
      Parameters:
      errorCode - 错误码
      errorMsg - 错误信息
      Returns:
      请求结果
    • ofThrowable

      public static <T> Result<T> ofThrowable(Throwable t)
      构造请求结果
      Type Parameters:
      T - 数据类型
      Parameters:
      t - 异常信息
      Returns:
      请求结果