Package org.ovirt.vdsm.jsonrpc.client
Class RequestBuilder
- java.lang.Object
-
- org.ovirt.vdsm.jsonrpc.client.RequestBuilder
-
public class RequestBuilder extends java.lang.ObjectUtility class which helps to buildJsonRpcRequestby providing information like method name and parameters.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringmethodNameprivate static com.fasterxml.jackson.databind.ObjectMapperOBJECT_MAPPERprivate com.fasterxml.jackson.databind.node.ObjectNodeparameters
-
Constructor Summary
Constructors Constructor Description RequestBuilder(java.lang.String methodName)Creates builder with required methodName.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonRpcRequestbuild()BuildsJsonRpcRequestbased on provided method name, parameter and generates id usingUUID.RequestBuilderwithOptionalParameter(java.lang.String name, java.lang.Object value)Adds parameter which is optional by method runtime and if not provided default value will be used during method execution.RequestBuilderwithOptionalParameter(java.lang.String name, java.lang.String value)Adds parameter which is optional by method runtime and if not provided default value will be used during method execution.RequestBuilderwithOptionalParameterAsList(java.lang.String name, java.util.List value)AddsListof values which is optional by method runtime and if not provided default value will be used during method execution.RequestBuilderwithOptionalParameterAsMap(java.lang.String name, java.util.Map value)AddsMapof values which is optional by method runtime and if not provided default value will be used during method execution.RequestBuilderwithParameter(java.lang.String name, java.lang.Object value)Adds parameter which is required by method runtime.RequestBuilderwithParameter(java.lang.String name, java.lang.String value)Adds parameter which is required by method runtime.
-
-
-
Method Detail
-
withParameter
public RequestBuilder withParameter(java.lang.String name, java.lang.String value)
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
public RequestBuilder withOptionalParameter(java.lang.String name, java.lang.String value)
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
public RequestBuilder withOptionalParameter(java.lang.String name, java.lang.Object value)
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
public RequestBuilder withOptionalParameterAsList(java.lang.String name, java.util.List value)
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
public RequestBuilder withOptionalParameterAsMap(java.lang.String name, java.util.Map value)
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
public RequestBuilder withParameter(java.lang.String name, java.lang.Object value)
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
public JsonRpcRequest build()
BuildsJsonRpcRequestbased on provided method name, parameter and generates id usingUUID.- Returns:
- Request object.
-
-