Package org.ovirt.vdsm.jsonrpc.client
Class ResponseBuilder
java.lang.Object
org.ovirt.vdsm.jsonrpc.client.ResponseBuilder
Utility class which helps to build
JsonRpcResponse by providing
information like response or error.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate com.fasterxml.jackson.databind.JsonNodeprivate com.fasterxml.jackson.databind.JsonNodeprivate static final com.fasterxml.jackson.databind.ObjectMapperprivate com.fasterxml.jackson.databind.JsonNode -
Constructor Summary
ConstructorsConstructorDescriptionResponseBuilder(com.fasterxml.jackson.databind.JsonNode id) Creates builder with required response id. -
Method Summary
Modifier and TypeMethodDescriptionbuild()BuildsJsonRpcResponsebased on provided id, result and error.Adds errorMapto the response.withResult(String result) Adds resultStringto the response.withResult(List<Object> result) Adds resultListto the response.withResult(Map<String, Object> result) Adds resultMapto the response.
-
Field Details
-
OBJECT_MAPPER
private static final com.fasterxml.jackson.databind.ObjectMapper OBJECT_MAPPER -
result
private com.fasterxml.jackson.databind.JsonNode result -
error
private com.fasterxml.jackson.databind.JsonNode error -
id
private com.fasterxml.jackson.databind.JsonNode id
-
-
Constructor Details
-
ResponseBuilder
public ResponseBuilder(com.fasterxml.jackson.databind.JsonNode id) Creates builder with required response id.- Parameters:
id- - Unique response Id.
-
-
Method Details
-
withResult
Adds resultMapto the response.- Parameters:
result-Mapwith response data.- Returns:
ResponseBuilderto let add more parameters.
-
withResult
Adds resultStringto the response.- Parameters:
result-Stringwith response data.- Returns:
ResponseBuilderto let add more parameters.
-
withResult
Adds resultListto the response.- Parameters:
result-Listwith response data.- Returns:
ResponseBuilderto let add more parameters.
-
withError
Adds errorMapto the response.- Parameters:
error-Mapwith error data.- Returns:
ResponseBuilderto let add more parameters.
-
build
BuildsJsonRpcResponsebased on provided id, result and error.- Returns:
- Response object.
-