Class Request

    • Constructor Detail

      • Request

        public Request​(String id,
                       String method)
        Creates a Request without parameters.

        If id is null the request id will be serialized as the JSON null value. If you want to omit the id, you should create a Notification.

        Parameters:
        id - A id of type String or null
        method - The non-null method you want to invoke
      • Request

        public Request​(String id,
                       String method,
                       com.google.gson.JsonArray params)
        Creates a Request with parameters in array format.

        If id is null the request id will be serialized as the JSON null value. If you want to omit the id you should create a Notification.

        If params is null a NullPointerException will be thrown. If you want to create a request without parameters, you should use Request(String, String)

        Parameters:
        id - A id of type String or null
        method - The non-null method you want to invoke
        params - The parameters provided as JsonArray
      • Request

        public Request​(String id,
                       String method,
                       com.google.gson.JsonObject params)
        Creates a Request with parameters in object format.

        If id is null the request id will be serialized as the JSON null value. If you want to omit the id you should create a Notification.

        If params is null a NullPointerException will be thrown. If you want to create a request without parameters, you should use Request(String, String)

        Parameters:
        id - A id of type String or null
        method - The non-null method you want to invoke
        params - The parameters provided as JsonObject
      • Request

        public Request​(Number id,
                       String method)
        Creates a Request without parameters.

        If id is null the request id will be serialized as the JSON null value. If you want to omit the id, you should create a Notification.

        Parameters:
        id - A id of type Number or null
        method - The non-null method you want to invoke
      • Request

        public Request​(Number id,
                       String method,
                       com.google.gson.JsonArray params)
        Creates a Request with parameters in array format.

        If id is null the request id will be serialized as the JSON null value. If you want to omit the id you should create a Notification.

        If params is null a NullPointerException will be thrown. If you want to create a request without parameters, you should use Request(Number, String)

        Parameters:
        id - A id of type Number or null
        method - The non-null method you want to invoke
        params - The parameters provided as JsonArray
      • Request

        public Request​(Number id,
                       String method,
                       com.google.gson.JsonObject params)
        Creates a Request with parameters in object format.

        If id is null the request id will be serialized as the JSON null value. If you want to omit the id you should create a Notification.

        If params is null a NullPointerException will be thrown. If you want to create a request without parameters, you should use Request(Number, String)

        Parameters:
        id - A id of type Number or null
        method - The non-null method you want to invoke
        params - The parameters provided as JsonObject
    • Method Detail

      • jsonrpc

        public String jsonrpc()
        Getter for jsonrpc field.

        It is always "2.0".

        Returns:
        The version of the JSON-RPC protocol
      • method

        public String method()
        Getter for method field.
        Returns:
        The name of the method to be invoked
      • hashCode

        public int hashCode()
        This method is implemented using Objects.hash().

        Overrides:
        hashCode in class Object
        Returns:
        The hash code for this Request
      • equals

        public boolean equals​(Object obj)
        This method returns true if the argument is a Request and all properties are equal, otherwise returns false.

        Overrides:
        equals in class Object
        Parameters:
        obj - The object to be checked
        Returns:
        Whether this is the same as the Object argument
      • toString

        public String toString()
        The returned String is equal to the value of: "Request@" + Integer.toHexString(hashCode()) + " " + contentAsJsonString() where contentAsJsonString() returns a JSON-like String of this Request.
        Overrides:
        toString in class Object
        Returns:
        A String representation of this Request
      • contentAsJsonString

        protected String contentAsJsonString()
        The returned String represents the contents of this Request.
        Returns:
        A JSON-like String of this Request