package com.usky.rule.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

@ApiModel
public class Result<T> {
    @ApiModelProperty("状态码")
    private String code;
    @ApiModelProperty("描述")
    private String message;
    @ApiModelProperty("数据")
    private T data;

    public static <T> Result<T> success() {
        return (Result<T>) result("200000", "", (Object)null);
    }

    public static <T> Result<T> success(T data) {
        return result("200000", "", data);
    }

    public static <T> Result<T> success(String message, T data) {
        return result("200000", message, data);
    }

    public static <T> Result<T> failure(String code, String message) {
        return (Result<T>) result(code, message, (Object)null);
    }

    public static <T> Result<T> failure(String code, String message, T data) {
        return result(code, message, data);
    }

    private static <T> Result<T> result(String code, String message, T data) {
        return new Result<T>(code, message, data);
    }

    public String getCode() {
        return this.code;
    }

    public String getMessage() {
        return this.message;
    }

    public T getData() {
        return this.data;
    }

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

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

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

    public boolean equals(final Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof Result)) {
            return false;
        } else {
            Result<?> other = (Result)o;
            if (!other.canEqual(this)) {
                return false;
            } else {
                Object this$code = this.getCode();
                Object other$code = other.getCode();
                if (this$code == null) {
                    if (other$code != null) {
                        return false;
                    }
                } else if (!this$code.equals(other$code)) {
                    return false;
                }

                Object this$message = this.getMessage();
                Object other$message = other.getMessage();
                if (this$message == null) {
                    if (other$message != null) {
                        return false;
                    }
                } else if (!this$message.equals(other$message)) {
                    return false;
                }

                Object this$data = this.getData();
                Object other$data = other.getData();
                if (this$data == null) {
                    if (other$data != null) {
                        return false;
                    }
                } else if (!this$data.equals(other$data)) {
                    return false;
                }

                return true;
            }
        }
    }

    protected boolean canEqual(final Object other) {
        return other instanceof Result;
    }

    public int hashCode() {
        int PRIME = 59;
        int result = 1;
        Object $code = this.getCode();
        result = result * 59 + ($code == null ? 43 : $code.hashCode());
        Object $message = this.getMessage();
        result = result * 59 + ($message == null ? 43 : $message.hashCode());
        Object $data = this.getData();
        result = result * 59 + ($data == null ? 43 : $data.hashCode());
        return result;
    }

    public String toString() {
        return "Result(code=" + this.getCode() + ", message=" + this.getMessage() + ", data=" + this.getData() + ")";
    }

    public Result() {
    }

    public Result(final String code, final String message, final T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }
}
