Class RestRequestBuilder

  • All Implemented Interfaces:
    org.refcodes.mixin.Dumpable, org.refcodes.web.HeaderFieldsAccessor<org.refcodes.web.RequestHeaderFields>, org.refcodes.web.HeaderFieldsAccessor.HeaderFieldsBuilder<org.refcodes.web.RequestHeaderFields,​RestRequestBuilder>, org.refcodes.web.HeaderFieldsAccessor.HeaderFieldsMutator<org.refcodes.web.RequestHeaderFields>, org.refcodes.web.HeaderFieldsAccessor.HeaderFieldsProperty<org.refcodes.web.RequestHeaderFields>, org.refcodes.web.HttpBodyAccessor.HttpBodyProvider<org.refcodes.web.BadRequestException>, org.refcodes.web.HttpMethodAccessor, org.refcodes.web.HttpMethodAccessor.HttpMethodBuilder<RestRequestBuilder>, org.refcodes.web.HttpMethodAccessor.HttpMethodMutator, org.refcodes.web.HttpMethodAccessor.HttpMethodProperty, org.refcodes.web.HttpRequest, org.refcodes.web.HttpRequestBuilder<RestRequestBuilder>, org.refcodes.web.RedirectDepthAccessor, org.refcodes.web.RedirectDepthAccessor.RedirectDepthBuilder<RestRequestBuilder>, org.refcodes.web.RedirectDepthAccessor.RedirectDepthMutator, org.refcodes.web.RedirectDepthAccessor.RedirectDepthProperty, org.refcodes.web.UrlAccessor, org.refcodes.web.UrlAccessor.UrlBuilder, org.refcodes.web.UrlAccessor.UrlMutator

    public class RestRequestBuilder
    extends RestRequest
    implements org.refcodes.web.HeaderFieldsAccessor.HeaderFieldsProperty<org.refcodes.web.RequestHeaderFields>, org.refcodes.mixin.Dumpable, org.refcodes.web.RedirectDepthAccessor.RedirectDepthBuilder<RestRequestBuilder>, org.refcodes.web.HttpRequestBuilder<RestRequestBuilder>, org.refcodes.web.HttpMethodAccessor.HttpMethodProperty, org.refcodes.web.HttpMethodAccessor.HttpMethodBuilder<RestRequestBuilder>, org.refcodes.web.HeaderFieldsAccessor.HeaderFieldsBuilder<org.refcodes.web.RequestHeaderFields,​RestRequestBuilder>
    The implementation of the RestResponseHandler interface as good old POJO for use by different RestClient implementations.
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.refcodes.web.HeaderFieldsAccessor

        org.refcodes.web.HeaderFieldsAccessor.HeaderFieldsBuilder<T extends org.refcodes.web.HeaderFields<?,​?>,​B extends org.refcodes.web.HeaderFieldsAccessor.HeaderFieldsBuilder<T,​B>>, org.refcodes.web.HeaderFieldsAccessor.HeaderFieldsMutator<T extends org.refcodes.web.HeaderFields<?,​?>>, org.refcodes.web.HeaderFieldsAccessor.HeaderFieldsProperty<T extends org.refcodes.web.HeaderFields<?,​?>>
      • Nested classes/interfaces inherited from interface org.refcodes.web.HttpMethodAccessor

        org.refcodes.web.HttpMethodAccessor.HttpMethodBuilder<B extends org.refcodes.web.HttpMethodAccessor.HttpMethodBuilder<B>>, org.refcodes.web.HttpMethodAccessor.HttpMethodMutator, org.refcodes.web.HttpMethodAccessor.HttpMethodProperty
      • Nested classes/interfaces inherited from interface org.refcodes.web.RedirectDepthAccessor

        org.refcodes.web.RedirectDepthAccessor.RedirectDepthBuilder<B extends org.refcodes.web.RedirectDepthAccessor.RedirectDepthBuilder<B>>, org.refcodes.web.RedirectDepthAccessor.RedirectDepthMutator, org.refcodes.web.RedirectDepthAccessor.RedirectDepthProperty
      • Nested classes/interfaces inherited from interface org.refcodes.web.UrlAccessor

        org.refcodes.web.UrlAccessor.UrlBuilder, org.refcodes.web.UrlAccessor.UrlMutator, org.refcodes.web.UrlAccessor.UrlProperty
    • Field Summary

      • Fields inherited from class org.refcodes.web.HttpClientRequest

        _mediaTypeFactoryLookup, DEFAULT_REDIRECT_DEPTH
      • Fields inherited from class org.refcodes.web.AbstractHttpRequest

        _headerFields, _httpMethod, _url
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected RestRequestBuilder​(RestClient aRestClient)
      Instantiates a new rest request builder impl.
      protected RestRequestBuilder​(org.refcodes.web.HttpMethod aHttpMethod, org.refcodes.web.Url aUrl, int aRedirectDepth, RestClient aRestClient)
      Instantiates a new rest request builder impl.
      protected RestRequestBuilder​(org.refcodes.web.HttpMethod aHttpMethod, org.refcodes.web.Url aUrl, Object aRequest, int aRedirectDepth, RestClient aRestClient)
      Instantiates a new rest request builder impl.
      protected RestRequestBuilder​(org.refcodes.web.HttpMethod aHttpMethod, org.refcodes.web.Url aUrl, Object aRequest, RestClient aRestClient)
      Instantiates a new rest request builder impl.
      protected RestRequestBuilder​(org.refcodes.web.HttpMethod aHttpMethod, org.refcodes.web.Url aUrl, RestClient aRestClient)
      Instantiates a new rest request builder impl.
      protected RestRequestBuilder​(org.refcodes.web.HttpMethod aHttpMethod, org.refcodes.web.Url aUrl, org.refcodes.web.RequestHeaderFields aHeaderFields, Object aRequest, int aRedirectDepth, RestClient aRestClient)
      Instantiates a new rest request builder impl.
      protected RestRequestBuilder​(org.refcodes.web.HttpMethod aHttpMethod, org.refcodes.web.Url aUrl, org.refcodes.web.RequestHeaderFields aHeaderFields, Object aRequest, RestClient aRestClient)
      Instantiates a new rest request builder impl.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      RestRequestBuilder build​(RestClient aRestClient)
      This is a convenience method for easily instantiating the according builder.
      org.refcodes.web.HttpMethod getHttpMethod()
      org.refcodes.web.UrlBuilder getUrl()
      void setHeaderFields​(org.refcodes.web.RequestHeaderFields aHeaderFields)
      void setHttpMethod​(org.refcodes.web.HttpMethod aHttpMethod)
      void setUrl​(org.refcodes.web.Url aUrl)
      RestResponse toRestResponse()
      Sends the request and returns synchronously the according RestResponse.
      String toString()
      RestRequestBuilder withHeaderFields​(org.refcodes.web.RequestHeaderFields aRequestHeaderFields)
      RestRequestBuilder withHttpMethod​(org.refcodes.web.HttpMethod aHttpMethod)
      RestRequestBuilder withRedirectDepth​(int aRedirectDepth)
      <REQ> RestRequestBuilder withRequest​(REQ aRequest)
      Sets the request for the request property.
      RestRequestBuilder withUrl​(org.refcodes.web.Url aUrl)
      • Methods inherited from class org.refcodes.web.HttpClientRequest

        getRedirectDepth, getRequest, setRedirectDepth, setRequest, toHttpBody
      • Methods inherited from class org.refcodes.web.AbstractHttpRequest

        getHeaderFields
      • Methods inherited from interface org.refcodes.mixin.Dumpable

        toDump, toDump, toPrintable
      • Methods inherited from interface org.refcodes.web.HeaderFieldsAccessor

        getHeaderFields
      • Methods inherited from interface org.refcodes.web.HeaderFieldsAccessor.HeaderFieldsProperty

        letHeaderFields
      • Methods inherited from interface org.refcodes.web.HttpMethodAccessor.HttpMethodProperty

        letHttpMethod
      • Methods inherited from interface org.refcodes.web.HttpRequestBuilder

        withAddToHeaderFields, withAddToHeaderFields, withAddToHeaderFields, withAddToHeaderFields, withAddToHeaderFields, withAddToQueryFields, withAddToQueryFields, withAddToQueryFields
      • Methods inherited from interface org.refcodes.web.RedirectDepthAccessor.RedirectDepthProperty

        letRedirectDepth
    • Constructor Detail

      • RestRequestBuilder

        protected RestRequestBuilder​(org.refcodes.web.HttpMethod aHttpMethod,
                                     org.refcodes.web.Url aUrl,
                                     org.refcodes.web.RequestHeaderFields aHeaderFields,
                                     Object aRequest,
                                     RestClient aRestClient)
        Instantiates a new rest request builder impl.
        Parameters:
        aHttpMethod - the http method
        aUrl - The Url from which to take the URL specific data.
        aHeaderFields - the Header-Fields
        aRequest - the request
        aRestClient - the rest client
      • RestRequestBuilder

        protected RestRequestBuilder​(org.refcodes.web.HttpMethod aHttpMethod,
                                     org.refcodes.web.Url aUrl,
                                     RestClient aRestClient)
        Instantiates a new rest request builder impl.
        Parameters:
        aHttpMethod - the http method
        aUrl - The Url from which to take the URL specific data.
        aRestClient - the rest client
      • RestRequestBuilder

        protected RestRequestBuilder​(RestClient aRestClient)
        Instantiates a new rest request builder impl.
        Parameters:
        aRestClient - the rest client
      • RestRequestBuilder

        protected RestRequestBuilder​(org.refcodes.web.HttpMethod aHttpMethod,
                                     org.refcodes.web.Url aUrl,
                                     Object aRequest,
                                     RestClient aRestClient)
        Instantiates a new rest request builder impl.
        Parameters:
        aHttpMethod - the http method
        aUrl - The Url from which to take the URL specific data.
        aRequest - the request
        aRestClient - the rest client
      • RestRequestBuilder

        protected RestRequestBuilder​(org.refcodes.web.HttpMethod aHttpMethod,
                                     org.refcodes.web.Url aUrl,
                                     int aRedirectDepth,
                                     RestClient aRestClient)
        Instantiates a new rest request builder impl.
        Parameters:
        aHttpMethod - the http method
        aUrl - The Url from which to take the URL specific data.
        aRedirectDepth - The redirect depth provides the count of HTTP-Request and HTTP-Response cycles where the response represents a redirect as of HttpStatusCode.isRedirectStatus(). A value of -1 represents the default behavior, e.g. using HttpURLConnection's redirection means.
        aRestClient - the rest client
      • RestRequestBuilder

        protected RestRequestBuilder​(org.refcodes.web.HttpMethod aHttpMethod,
                                     org.refcodes.web.Url aUrl,
                                     Object aRequest,
                                     int aRedirectDepth,
                                     RestClient aRestClient)
        Instantiates a new rest request builder impl.
        Parameters:
        aHttpMethod - the http method
        aUrl - The Url from which to take the URL specific data.
        aRequest - the request
        aRedirectDepth - The redirect depth provides the count of HTTP-Request and HTTP-Response cycles where the response represents a redirect as of HttpStatusCode.isRedirectStatus(). A value of -1 represents the default behavior, e.g. using HttpURLConnection's redirection means.
        aRestClient - the rest client
      • RestRequestBuilder

        protected RestRequestBuilder​(org.refcodes.web.HttpMethod aHttpMethod,
                                     org.refcodes.web.Url aUrl,
                                     org.refcodes.web.RequestHeaderFields aHeaderFields,
                                     Object aRequest,
                                     int aRedirectDepth,
                                     RestClient aRestClient)
        Instantiates a new rest request builder impl.
        Parameters:
        aHttpMethod - the http method
        aUrl - The Url from which to take the URL specific data.
        aHeaderFields - the Header-Fields
        aRequest - the request
        aRedirectDepth - The redirect depth provides the count of HTTP-Request and HTTP-Response cycles where the response represents a redirect as of HttpStatusCode.isRedirectStatus(). A value of -1 represents the default behavior, e.g. using HttpURLConnection's redirection means.
        aRestClient - the rest client
    • Method Detail

      • withUrl

        public RestRequestBuilder withUrl​(org.refcodes.web.Url aUrl)
        Specified by:
        withUrl in interface org.refcodes.web.UrlAccessor.UrlBuilder
      • withHttpMethod

        public RestRequestBuilder withHttpMethod​(org.refcodes.web.HttpMethod aHttpMethod)
        Specified by:
        withHttpMethod in interface org.refcodes.web.HttpMethodAccessor.HttpMethodBuilder<RestRequestBuilder>
      • withRequest

        public <REQ> RestRequestBuilder withRequest​(REQ aRequest)
        Sets the request for the request property.
        Type Parameters:
        REQ - the generic type
        Parameters:
        aRequest - The request to be stored by the request property.
        Returns:
        The builder for applying multiple build operations.
      • withHeaderFields

        public RestRequestBuilder withHeaderFields​(org.refcodes.web.RequestHeaderFields aRequestHeaderFields)
        Specified by:
        withHeaderFields in interface org.refcodes.web.HeaderFieldsAccessor.HeaderFieldsBuilder<org.refcodes.web.RequestHeaderFields,​RestRequestBuilder>
      • withRedirectDepth

        public RestRequestBuilder withRedirectDepth​(int aRedirectDepth)
        Specified by:
        withRedirectDepth in interface org.refcodes.web.RedirectDepthAccessor.RedirectDepthBuilder<RestRequestBuilder>
      • build

        public RestRequestBuilder build​(RestClient aRestClient)
        This is a convenience method for easily instantiating the according builder.
        Overrides:
        build in class RestRequest
        Parameters:
        aRestClient - the rest client
        Returns:
        an instance (using a public implementation) of this builder
      • getUrl

        public org.refcodes.web.UrlBuilder getUrl()
        Specified by:
        getUrl in interface org.refcodes.web.UrlAccessor
        Overrides:
        getUrl in class RestRequest
      • setUrl

        public void setUrl​(org.refcodes.web.Url aUrl)
        Specified by:
        setUrl in interface org.refcodes.web.UrlAccessor.UrlMutator
      • getHttpMethod

        public org.refcodes.web.HttpMethod getHttpMethod()
        Specified by:
        getHttpMethod in interface org.refcodes.web.HttpMethodAccessor
        Overrides:
        getHttpMethod in class RestRequest
      • setHttpMethod

        public void setHttpMethod​(org.refcodes.web.HttpMethod aHttpMethod)
        Specified by:
        setHttpMethod in interface org.refcodes.web.HttpMethodAccessor.HttpMethodMutator
      • setHeaderFields

        public void setHeaderFields​(org.refcodes.web.RequestHeaderFields aHeaderFields)
        Specified by:
        setHeaderFields in interface org.refcodes.web.HeaderFieldsAccessor.HeaderFieldsMutator<org.refcodes.web.RequestHeaderFields>
        Overrides:
        setHeaderFields in class RestRequest
      • toRestResponse

        public RestResponse toRestResponse()
                                    throws org.refcodes.web.HttpResponseException
        Sends the request and returns synchronously the according RestResponse.
        Overrides:
        toRestResponse in class RestRequest
        Returns:
        the rest response
        Throws:
        org.refcodes.web.HttpResponseException - the http response exception