Class RequestBuilder


  • public class RequestBuilder
    extends java.lang.Object
    Utility class which helps to build JsonRpcRequest by providing information like method name and parameters.
    • 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
      JsonRpcRequest build()
      Builds JsonRpcRequest based on provided method name, parameter and generates id using UUID.
      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.
      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.
      RequestBuilder withOptionalParameterAsList​(java.lang.String name, java.util.List value)
      Adds List of values which is optional by method runtime and if not provided default value will be used during method execution.
      RequestBuilder withOptionalParameterAsMap​(java.lang.String name, java.util.Map value)
      Adds Map of values which is optional by method runtime and if not provided default value will be used during method execution.
      RequestBuilder withParameter​(java.lang.String name, java.lang.Object value)
      Adds parameter which is required by method runtime.
      RequestBuilder withParameter​(java.lang.String name, java.lang.String value)
      Adds parameter which is required by method runtime.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RequestBuilder

        public RequestBuilder​(java.lang.String methodName)
        Creates builder with required methodName.
        Parameters:
        methodName - - Name of the method to call.
    • 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:
        RequestBuilder to 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 or null.
        Returns:
        RequestBuilder to 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 or null.
        Returns:
        RequestBuilder to let add more parameters.
      • withOptionalParameterAsList

        public RequestBuilder withOptionalParameterAsList​(java.lang.String name,
                                                          java.util.List value)
        Adds List of 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 - - List of values which may be null or empty List.
        Returns:
        RequestBuilder to let add more parameters.
      • withOptionalParameterAsMap

        public RequestBuilder withOptionalParameterAsMap​(java.lang.String name,
                                                         java.util.Map value)
        Adds Map of 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 - - Map of values which may be null or empty Map.
        Returns:
        RequestBuilder to 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 than String.
        Returns:
        RequestBuilder to let add more parameters.
      • build

        public JsonRpcRequest build()
        Builds JsonRpcRequest based on provided method name, parameter and generates id using UUID.
        Returns:
        Request object.