public class JsonRPCResponse extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
CALLBACK_METHOD_NAME
The method name indicating a callback.
|
static String |
ERROR_CODE_FIELD_NAME
The field name of the JSON RPC "code" field.
|
static String |
ERROR_DATA_FIELD_NAME
The field name of the JSON RPC "data" field.
|
static String |
ERROR_FIELD_NAME
The field name of the JSON RPC "error" field.
|
static String |
ERROR_MESSAGE_FIELD_NAME
The field name of the JSON RPC "message" field.
|
static String |
ID_FIELD_NAME
The field name of the JSON RPC "id" field.
|
static String |
METHOD_FIELD_NAME
The field name of the JSON RPC "method" field.
|
static String |
PARAMETERS_FIELD_NAME
The field name of the JSON RPC "method" field.
|
static String |
RESULT_FIELD_NAME
The field name of the JSON RPC "result" field.
|
| Constructor and Description |
|---|
JsonRPCResponse(com.fasterxml.jackson.databind.JsonNode rawJsonResponse)
Create a new
JsonRPCResponse instance. |
| Modifier and Type | Method and Description |
|---|---|
com.fasterxml.jackson.databind.JsonNode |
getRawJsonResponse()
Get the raw JSON response that is wrapped by this
JsonRPCResponse
instance. |
BeowulfResponseException |
handleError(long id)
This method checks if the JSON response wrapped by this
JsonRPCResponse instance has the expected id and
will try to generate and throw a BeowulfResponseException based on
the response. |
<T> List<T> |
handleResult(com.fasterxml.jackson.databind.JavaType type,
long id)
This method checks if the JSON response wrapped by this
JsonRPCResponse instance has the expected id and
will try to transform the JSON into the given type. |
boolean |
isError()
Check if the
getRawJsonResponse() contains an error. |
boolean |
isFieldNullOrEmpty(String fieldName,
com.fasterxml.jackson.databind.node.ObjectNode response)
Check if the given
fieldName has an empty or null value. |
String |
toString() |
public static final String ERROR_FIELD_NAME
public static final String ERROR_CODE_FIELD_NAME
public static final String ERROR_MESSAGE_FIELD_NAME
public static final String ERROR_DATA_FIELD_NAME
public static final String METHOD_FIELD_NAME
public static final String PARAMETERS_FIELD_NAME
public static final String ID_FIELD_NAME
public static final String RESULT_FIELD_NAME
public static final String CALLBACK_METHOD_NAME
public JsonRPCResponse(com.fasterxml.jackson.databind.JsonNode rawJsonResponse)
JsonRPCResponse instance.rawJsonResponse - The raw JSON response that should be wrapped by this
JsonRPCResponse instance.public com.fasterxml.jackson.databind.JsonNode getRawJsonResponse()
JsonRPCResponse
instance.JsonRPCResponse instance.public <T> List<T> handleResult(com.fasterxml.jackson.databind.JavaType type, long id) throws BeowulfCommunicationException
JsonRPCResponse instance has the expected id and
will try to transform the JSON into the given type.T - The JavaType of typetype - The type to transform the JSON to.id - The expected id of the response.type instances.BeowulfCommunicationException - If the response does not contain the expected id
or if the response could not be transformed into the expected
type.public boolean isError()
getRawJsonResponse() contains an error.true if the response contains an error,
false otherwise.public BeowulfResponseException handleError(long id) throws BeowulfCommunicationException
JsonRPCResponse instance has the expected id and
will try to generate and throw a BeowulfResponseException based on
the response.id - The expected id of the response.BeowulfResponseException based on the Json response.BeowulfCommunicationException - If the response does not contain the expected id
or the response do not contain an error.public boolean isFieldNullOrEmpty(String fieldName, com.fasterxml.jackson.databind.node.ObjectNode response)
fieldName has an empty or null value.fieldName - The field name to check.response - The response to check.true if the fieldName has an empty or
null value.Copyright © 2019. All rights reserved.