package com.usky.sas.common.exception;


import com.usky.sas.common.enums.BusinessEnum;

public class BusinessException extends RuntimeException {
    private String message;
    private int code;

    public BusinessException(int code, String message) {
        super(message);
        this.code = code;
    }

    public BusinessException(String message, int code) {
        this.message = message;
        this.code = code;
    }

    public BusinessException(BusinessEnum businessEnum) {
        this.message = businessEnum.getDescription();
        this.code = businessEnum.getCode();
    }

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

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

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

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

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof BusinessException)) {
            return false;
        } else {
            BusinessException other = (BusinessException)o;
            if (!other.canEqual(this)) {
                return false;
            } else {
                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;
                }

                if (this.getCode() != other.getCode()) {
                    return false;
                } else {
                    return true;
                }
            }
        }
    }

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

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

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