Package org.ovirt.vdsm.jsonrpc.client
Class RequestBuilder
java.lang.Object
org.ovirt.vdsm.jsonrpc.client.RequestBuilder
Utility class which helps to build
JsonRpcRequest by providing
information like method name and parameters.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Stringprivate static final com.fasterxml.jackson.databind.ObjectMapperprivate final com.fasterxml.jackson.databind.node.ObjectNode -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()BuildsJsonRpcRequestbased on provided method name, parameter and generates id usingUUID.withOptionalParameter(String name, Object value) Adds parameter which is optional by method runtime and if not provided default value will be used during method execution.withOptionalParameter(String name, String value) Adds parameter which is optional by method runtime and if not provided default value will be used during method execution.withOptionalParameterAsList(String name, List value) AddsListof values which is optional by method runtime and if not provided default value will be used during method execution.withOptionalParameterAsMap(String name, Map value) AddsMapof values which is optional by method runtime and if not provided default value will be used during method execution.withParameter(String name, Object value) Adds parameter which is required by method runtime.withParameter(String name, String value) Adds parameter which is required by method runtime.
-
Field Details
-
OBJECT_MAPPER
private static final com.fasterxml.jackson.databind.ObjectMapper OBJECT_MAPPER -
parameters
private final com.fasterxml.jackson.databind.node.ObjectNode parameters -
methodName
-
-
Constructor Details
-
RequestBuilder
Creates builder with required methodName.- Parameters:
methodName- - Name of the method to call.
-
-
Method Details
-
withParameter
Adds parameter which is required by method runtime.- Parameters:
name- - Name of the parameter.value- - Value of the parameter.- Returns:
RequestBuilderto let add more parameters.
-
withOptionalParameter
Adds parameter which is optional by method runtime and if not provided default value will be used during method execution.- Parameters:
name- - Name of the parameter.value- - Value of the parameter ornull.- Returns:
RequestBuilderto let add more parameters.
-
withOptionalParameter
Adds parameter which is optional by method runtime and if not provided default value will be used during method execution.- Parameters:
name- - Name of the parameter.value- - Value of the parameter ornull.- Returns:
RequestBuilderto let add more parameters.
-
withOptionalParameterAsList
AddsListof values which is optional by method runtime and if not provided default value will be used during method execution.- Parameters:
name- - Name of the parameter.value- -Listof values which may benullor emptyList.- Returns:
RequestBuilderto let add more parameters.
-
withOptionalParameterAsMap
AddsMapof values which is optional by method runtime and if not provided default value will be used during method execution.- Parameters:
name- - Name of the parameter.value- -Mapof values which may benullor emptyMap.- Returns:
RequestBuilderto let add more parameters.
-
withParameter
Adds parameter which is required by method runtime.- Parameters:
name- - Name of the parameter.value- - Value of the parameter which is different thanString.- Returns:
RequestBuilderto let add more parameters.
-
build
BuildsJsonRpcRequestbased on provided method name, parameter and generates id usingUUID.- Returns:
- Request object.
-