public interface JsonRpcParams
A representation of a JSON-RPC params.
-
Method Summary
Modifier and TypeMethodDescription<T> TMap all request params to a bean class type using JSONB.Access all request params as a single JSON array.Access all request params as a single JSON object.Access all request params as a single JSON structure.static JsonRpcParamscreate(JsonStructure params) Create an instance from a JSON structure.find(int index) Get a single array param by index as a JSON value, if present.Get a single param by name as a JSON value, if present.get(int index) Get a single array param by index as a JSON value.Get a single param by name as a JSON value.getString(int index) Get a single array param by index as a string.Get a single param by name as a string.
-
Method Details
-
create
Create an instance from a JSON structure.- Parameters:
params- the structure- Returns:
- a new instance of this class
-
asJsonObject
JsonObject asJsonObject()Access all request params as a single JSON object.- Returns:
- a JSON object
- Throws:
ClassCastException- if not a JSON object
-
asJsonArray
JsonArray asJsonArray()Access all request params as a single JSON array.- Returns:
- a JSON array
- Throws:
ClassCastException- if not a JSON array
-
asJsonStructure
JsonStructure asJsonStructure()Access all request params as a single JSON structure.- Returns:
- a JSON structure
-
get
Get a single param by name as a JSON value.- Parameters:
name- param name- Returns:
- the param value
- Throws:
ClassCastException- if not a JSON objectIllegalArgumentException- if the param does not exist
-
getString
Get a single param by name as a string.- Parameters:
name- param name- Returns:
- the param value as a string
- Throws:
ClassCastException- if not a JSON object or value not a stringIllegalArgumentException- if the param does not exist
-
find
Get a single param by name as a JSON value, if present.- Parameters:
name- param name- Returns:
- an optional param value
- Throws:
ClassCastException- if not a JSON object
-
get
Get a single array param by index as a JSON value.- Parameters:
index- the index- Returns:
- the param value
- Throws:
ClassCastException- if not a JSON arrayIndexOutOfBoundsException- if index is out of bounds
-
getString
Get a single array param by index as a string.- Parameters:
index- the index- Returns:
- the param value as a string
- Throws:
ClassCastException- if not a JSON array or value not a stringIndexOutOfBoundsException- if index is out of bounds
-
find
Get a single array param by index as a JSON value, if present.- Parameters:
index- the index- Returns:
- an optional param value
- Throws:
ClassCastException- if not a JSON arrayIndexOutOfBoundsException- if index is out of bounds
-
as
Map all request params to a bean class type using JSONB.- Type Parameters:
T- the bean type- Parameters:
type- the bean class- Returns:
- an instance of the bean type
- Throws:
JsonbException- if an error occurs during mapping
-