Class Request
- java.lang.Object
-
- eliasstar.jsonrpc.objects.Request
-
- Direct Known Subclasses:
Notification
public class Request extends Object
Represents a JSON-RPC request.- Since:
- 0.1.0
- Author:
- Elias*
- See Also:
- JSON-RPC Specification
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedRequest(Id<?> id, String method, Parameters<?> params)Creates aRequest.Request(Number id, String method)Creates aRequestwithout parameters.Request(Number id, String method, com.google.gson.JsonArray params)Creates aRequestwith parameters in array format.Request(Number id, String method, com.google.gson.JsonObject params)Creates aRequestwith parameters in object format.Request(String id, String method)Creates aRequestwithout parameters.Request(String id, String method, com.google.gson.JsonArray params)Creates aRequestwith parameters in array format.Request(String id, String method, com.google.gson.JsonObject params)Creates aRequestwith parameters in object format.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringcontentAsJsonString()booleanequals(Object obj)This method returnstrueif the argument is aRequestand all properties are equal, otherwise returnsfalse.inthashCode()This method is implemented usingObjects.hash().Optional<Id<?>>id()Getter for id field.Stringjsonrpc()Getter for jsonrpc field.Stringmethod()Getter for method field.Optional<Parameters<?>>params()Getter for params field.StringtoString()
-
-
-
Constructor Detail
-
Request
protected Request(Id<?> id, String method, Parameters<?> params)
Creates aRequest.- Parameters:
id- If null theRequestis considered to be aNotificationmethod- Must not be nullparams- If null theRequesthas no params
-
Request
public Request(String id, String method)
Creates aRequestwithout parameters.If id is
nullthe request id will be serialized as the JSONnullvalue. If you want to omit the id, you should create aNotification.- Parameters:
id- A id of typeStringornullmethod- The non-null method you want to invoke
-
Request
public Request(String id, String method, com.google.gson.JsonArray params)
Creates aRequestwith parameters in array format.If id is
nullthe request id will be serialized as the JSONnullvalue. If you want to omit the id you should create aNotification.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 typeStringornullmethod- The non-null method you want to invokeparams- The parameters provided asJsonArray
-
Request
public Request(String id, String method, com.google.gson.JsonObject params)
Creates aRequestwith parameters in object format.If id is
nullthe request id will be serialized as the JSONnullvalue. If you want to omit the id you should create aNotification.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 typeStringornullmethod- The non-null method you want to invokeparams- The parameters provided asJsonObject
-
Request
public Request(Number id, String method)
Creates aRequestwithout parameters.If id is
nullthe request id will be serialized as the JSONnullvalue. If you want to omit the id, you should create aNotification.- Parameters:
id- A id of typeNumberornullmethod- The non-null method you want to invoke
-
Request
public Request(Number id, String method, com.google.gson.JsonArray params)
Creates aRequestwith parameters in array format.If id is
nullthe request id will be serialized as the JSONnullvalue. If you want to omit the id you should create aNotification.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 typeNumberornullmethod- The non-null method you want to invokeparams- The parameters provided asJsonArray
-
Request
public Request(Number id, String method, com.google.gson.JsonObject params)
Creates aRequestwith parameters in object format.If id is
nullthe request id will be serialized as the JSONnullvalue. If you want to omit the id you should create aNotification.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 typeNumberornullmethod- The non-null method you want to invokeparams- The parameters provided asJsonObject
-
-
Method Detail
-
jsonrpc
public String jsonrpc()
Getter for jsonrpc field.It is always
"2.0".- Returns:
- The version of the JSON-RPC protocol
-
id
public Optional<Id<?>> id()
Getter for id field.If the
Optionalis empty theRequestis considered to be aNotification.- Returns:
- The id of this
Request
-
method
public String method()
Getter for method field.- Returns:
- The name of the method to be invoked
-
params
public Optional<Parameters<?>> params()
Getter for params field.- Returns:
- The parameters of this
Request
-
hashCode
public int hashCode()
This method is implemented usingObjects.hash().
-
equals
public boolean equals(Object obj)
This method returnstrueif the argument is aRequestand all properties are equal, otherwise returnsfalse.
-
toString
public String toString()
-
-