Package org.jgrapes.webconsole.base
Class JsonRpc
java.lang.Object
org.jgrapes.webconsole.base.JsonRpc
- Direct Known Subclasses:
WcJsonRpc
A class that serializes/deserializes as a JSON RPC.
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdds the param.static void
Adds the parameter types for the given method.asString
(int index) Returns the parameter’s value as string.Optional
<com.fasterxml.jackson.databind.JsonNode> id()
An optional request id.method()
The invoked method.<T> T
param
(int index) Returns the parameter’s value as the requested type.Object[]
params()
The parameters.Sets the id.Sets the id.Sets the params.static void
Specify the types of the parameters for specific methods.<T> Stream
<T> Returns the parameter’s value as stream.toString()
To string.
-
Constructor Details
-
JsonRpc
public JsonRpc()Instantiates a new json rpc. -
JsonRpc
Instantiates a new json rpc.- Parameters:
method
- the method
-
-
Method Details
-
setParamTypes
Specify the types of the parameters for specific methods.Used for deserialization.
- Parameters:
clazz
- the clazztypes
- the param types
-
addParamTypes
Adds the parameter types for the given method.Used for deserialization.
- Parameters:
clazz
- the clazzmethod
- the methodtypes
- the types
-
id
An optional request id.- Returns:
- the id
-
setId
Sets the id.- Parameters:
id
- the id- Returns:
- the json rpc
-
setId
Sets the id.- Parameters:
id
- the id- Returns:
- the json rpc
-
method
The invoked method.- Returns:
- the method
-
params
The parameters.- Returns:
- the params
-
setParams
Sets the params.- Parameters:
params
- the params- Returns:
- the json rpc
-
addParam
Adds the param.- Parameters:
param
- the param- Returns:
- the json rpc
-
asString
Returns the parameter’s value as string.- Parameters:
index
- the index- Returns:
- the string
-
param
Returns the parameter’s value as the requested type.- Type Parameters:
T
- the generic type- Parameters:
index
- the index- Returns:
- the string
-
streamOf
Returns the parameter’s value as stream.- Type Parameters:
T
- the generic type- Parameters:
cls
- the class of the stream elementsindex
- the index of the parameter- Returns:
- the stream
-
toString
To string.
-