Class JsonRpcResponse


  • public class JsonRpcResponse
    extends JsonRpcMessage
    This class models a JSON-RPC Response.
    • Method Detail

      • createResult

        public static JsonRpcResponse createResult​(Object result,
                                                   Object id)
        Creates a JSON-RPC response with a result.
        Parameters:
        result - the result
        id - the response ID (string, number or null)
        Returns:
        the response
      • createError

        public static JsonRpcResponse createError​(JsonRpcResponse.Error error,
                                                  Object id)
        Creates a JSON-RPC response with an error.
        Parameters:
        error - the error
        id - the response ID (string, number or null)
        Returns:
        the response
      • getResult

        public Object getResult()
        Returns the result. If this response doesn't contain a result, this method returns null and getError() should return an error.
        Returns:
        the result or null
      • getError

        public JsonRpcResponse.Error getError()
        Returns the error, if this response contains an error. Otherwise it returns null and getResult() should return a result.
        Returns:
        the error or null
      • getID

        public Object getID()
        Returns the request ID (string, number or null).
        Returns:
        the request ID (string, number or null)