All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.deansquirrel.tools.http.ResponseResult Maven / Gradle / Ivy

The newest version!
package com.github.deansquirrel.tools.http;

public class ResponseResult {

    public static int SUCCESS = 0;
    public static int FAIL = -1;
    public static String MSG_SUCCESS = "成功";
    public static String MSG_FAIL = "失败";

    protected int code = 0;
    protected String message;
    protected T data;

    public ResponseResult() {
    }

    public ResponseResult(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public static  ResponseResult success() {
        return new ResponseResult<>(ResponseResult.SUCCESS, ResponseResult.MSG_SUCCESS, null);
    }

    public static  ResponseResult success(T data) {
        return new ResponseResult<>(ResponseResult.SUCCESS, ResponseResult.MSG_SUCCESS, data);
    }

    public static  ResponseResult success(String message, T data) {
        return new ResponseResult<>(ResponseResult.SUCCESS, message, data);
    }

    public static  ResponseResult fail() {
        return new ResponseResult<>(ResponseResult.FAIL, ResponseResult.MSG_FAIL, null);
    }

    public static  ResponseResult fail(String message) {
        return new ResponseResult<>(ResponseResult.FAIL, message, null);
    }

    public static  ResponseResult fail(int code, String message) {
        return new ResponseResult<>(code, message, null);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy