package com.usky.sas.service.dto.agbox;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.HashMap;
import java.util.Map;

@JsonInclude(Include.NON_NULL)
public class JsonRpcRequest {
    private String jsonrpc = "2.0";
    private String method;
    private Object params;
    private Long id;

    public JsonRpcRequest(String method, Object params, Long id) {
        this.method = method;
        this.params = params;
        this.id = id;
    }

    public String toString() {
        try {
            return (new ObjectMapper()).writeValueAsString(this);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public static void main(String[] args) {
        int a = 5;
        int b = 3;
        Map<String, Object> map = new HashMap();
        map.put("a", a);
        map.put("b", b);
        JsonRpcRequest request = new JsonRpcRequest("add", map, 1L);
        System.out.println(request);
    }

    public String getJsonrpc() {
        return this.jsonrpc;
    }

    public String getMethod() {
        return this.method;
    }

    public Object getParams() {
        return this.params;
    }

    public Long getId() {
        return this.id;
    }

    public void setJsonrpc(String jsonrpc) {
        this.jsonrpc = jsonrpc;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public void setParams(Object params) {
        this.params = params;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof JsonRpcRequest)) {
            return false;
        } else {
            JsonRpcRequest other = (JsonRpcRequest)o;
            if (!other.canEqual(this)) {
                return false;
            } else {
                Object this$jsonrpc = this.getJsonrpc();
                Object other$jsonrpc = other.getJsonrpc();
                if (this$jsonrpc == null) {
                    if (other$jsonrpc != null) {
                        return false;
                    }
                } else if (!this$jsonrpc.equals(other$jsonrpc)) {
                    return false;
                }

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

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

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

                return true;
            }
        }
    }

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

    public int hashCode() {
        int PRIME = 59;
        int result = 1;
        Object $jsonrpc = this.getJsonrpc();
        result = result * 59 + ($jsonrpc == null ? 43 : $jsonrpc.hashCode());
        Object $method = this.getMethod();
        result = result * 59 + ($method == null ? 43 : $method.hashCode());
        Object $params = this.getParams();
        result = result * 59 + ($params == null ? 43 : $params.hashCode());
        Object $id = this.getId();
        result = result * 59 + ($id == null ? 43 : $id.hashCode());
        return result;
    }
}
