Class RestResponseResult

java.lang.Object
org.refcodes.web.AbstractHttpRequest
org.refcodes.web.HttpClientRequest
org.refcodes.rest.RestResponseResult
All Implemented Interfaces:
org.refcodes.component.Closable, org.refcodes.component.Closable.CloseBuilder<org.refcodes.component.LinkComponent.LinkComponentBuilder<RestResponseResult>>, org.refcodes.component.ConnectionStatusAccessor, org.refcodes.component.LinkComponent, org.refcodes.component.LinkComponent.LinkComponentBuilder<RestResponseResult>, org.refcodes.component.Openable, org.refcodes.component.Openable.OpenBuilder<org.refcodes.component.LinkComponent.LinkComponentBuilder<RestResponseResult>>, org.refcodes.component.OpenedAccessor, org.refcodes.io.IOResultAccessor<RestResponse,InterruptedException>, org.refcodes.mixin.ResponseAccessor<RestResponse>, org.refcodes.mixin.ResultAccessor<RestResponse,InterruptedException>, RestResponseConsumer, org.refcodes.web.HeaderFieldsAccessor<org.refcodes.web.RequestHeaderFields>, org.refcodes.web.HeaderFieldsAccessor.HeaderFieldsBuilder<org.refcodes.web.RequestHeaderFields,RestResponseResult>, 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<RestResponseResult>, org.refcodes.web.HttpMethodAccessor.HttpMethodMutator, org.refcodes.web.HttpMethodAccessor.HttpMethodProperty, org.refcodes.web.HttpRequest, org.refcodes.web.HttpRequestBuilder<RestResponseResult>, org.refcodes.web.QueryFieldsAccessor, org.refcodes.web.QueryFieldsAccessor.QueryFieldsMutator, org.refcodes.web.QueryFieldsAccessor.QueryFieldsProperty, org.refcodes.web.RedirectDepthAccessor, org.refcodes.web.RedirectDepthAccessor.RedirectDepthBuilder<RestResponseResult>, 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 RestResponseResult extends org.refcodes.web.HttpClientRequest implements RestResponseConsumer, org.refcodes.web.QueryFieldsAccessor.QueryFieldsProperty, org.refcodes.web.HeaderFieldsAccessor.HeaderFieldsProperty<org.refcodes.web.RequestHeaderFields>, org.refcodes.web.RedirectDepthAccessor.RedirectDepthBuilder<RestResponseResult>, org.refcodes.web.HttpRequestBuilder<RestResponseResult>, org.refcodes.web.HttpMethodAccessor.HttpMethodProperty, org.refcodes.web.HttpMethodAccessor.HttpMethodBuilder<RestResponseResult>, org.refcodes.component.LinkComponent.LinkComponentBuilder<RestResponseResult>, org.refcodes.component.ConnectionStatusAccessor, org.refcodes.web.HeaderFieldsAccessor.HeaderFieldsBuilder<org.refcodes.web.RequestHeaderFields,RestResponseResult>, org.refcodes.io.IOResultAccessor<RestResponse,InterruptedException>, org.refcodes.mixin.ResponseAccessor<RestResponse>
A RestResponseResult handles a REST request asynchronously on the RestClient instance's side to do the actual technical implementation of sending that request (or mocking the send-out of a request).
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.refcodes.component.Closable

    org.refcodes.component.Closable.CloseAutomaton, org.refcodes.component.Closable.CloseBuilder<B extends org.refcodes.component.Closable.CloseBuilder<B>>

    Nested classes/interfaces inherited from interface org.refcodes.component.ConnectionStatusAccessor

    org.refcodes.component.ConnectionStatusAccessor.ConnectionStatusMutator, org.refcodes.component.ConnectionStatusAccessor.ConnectionStatusProperty

    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.component.LinkComponent

    org.refcodes.component.LinkComponent.LinkAutomaton, org.refcodes.component.LinkComponent.LinkComponentBuilder<B extends org.refcodes.component.LinkComponent.LinkComponentBuilder<B>>

    Nested classes/interfaces inherited from interface org.refcodes.component.Openable

    org.refcodes.component.Openable.OpenAutomaton, org.refcodes.component.Openable.OpenBuilder<B extends org.refcodes.component.Openable.OpenBuilder<B>>

    Nested classes/interfaces inherited from interface org.refcodes.component.OpenedAccessor

    org.refcodes.component.OpenedAccessor.OpenedMutator, org.refcodes.component.OpenedAccessor.OpenedProperty

    Nested classes/interfaces inherited from interface org.refcodes.web.QueryFieldsAccessor

    org.refcodes.web.QueryFieldsAccessor.QueryFieldsBuilder<B extends org.refcodes.web.QueryFieldsAccessor.QueryFieldsBuilder<?>>, org.refcodes.web.QueryFieldsAccessor.QueryFieldsMutator, org.refcodes.web.QueryFieldsAccessor.QueryFieldsProperty

    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.mixin.ResponseAccessor

    org.refcodes.mixin.ResponseAccessor.ResponseBuilder<RES extends Object,B extends org.refcodes.mixin.ResponseAccessor.ResponseBuilder<RES,B>>, org.refcodes.mixin.ResponseAccessor.ResponseMutator<RES extends Object>, org.refcodes.mixin.ResponseAccessor.ResponseProperty<RES extends Object>

    Nested classes/interfaces inherited from interface org.refcodes.mixin.ResultAccessor

    org.refcodes.mixin.ResultAccessor.ResultBuilder<RES extends Object,B extends org.refcodes.mixin.ResultAccessor.ResultBuilder<RES,B>>, org.refcodes.mixin.ResultAccessor.ResultMutator<RES extends Object>, org.refcodes.mixin.ResultAccessor.ResultProperty<RES extends Object,EXC extends Exception>

    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
    Constructor
    Description
    RestResponseResult(org.refcodes.web.HttpMethod aHttpMethod, org.refcodes.web.Url aUrl, int aRedirectDepth, org.refcodes.web.MediaTypeFactoryLookup aMediaTypeFactoryLookup)
    Instantiates a new RestResponseResult.
    RestResponseResult(org.refcodes.web.HttpMethod aHttpMethod, org.refcodes.web.Url aUrl, Object aRequest, int aRedirectDepth, org.refcodes.web.MediaTypeFactoryLookup aMediaTypeFactoryLookup)
    Instantiates a new RestResponseResult.
    RestResponseResult(org.refcodes.web.HttpMethod aHttpMethod, org.refcodes.web.Url aUrl, Object aRequest, org.refcodes.web.MediaTypeFactoryLookup aMediaTypeFactoryLookup)
    Instantiates a new RestResponseResult.
    RestResponseResult(org.refcodes.web.HttpMethod aHttpMethod, org.refcodes.web.Url aUrl, org.refcodes.web.MediaTypeFactoryLookup aMediaTypeFactoryLookup)
    Instantiates a new RestResponseResult.
    RestResponseResult(org.refcodes.web.HttpMethod aHttpMethod, org.refcodes.web.Url aUrl, org.refcodes.web.RequestHeaderFields aHeaderFields, Object aRequest, int aRedirectDepth, org.refcodes.web.MediaTypeFactoryLookup aMediaTypeFactoryLookup)
    Instantiates a new RestResponseResult.
    RestResponseResult(org.refcodes.web.HttpMethod aHttpMethod, org.refcodes.web.Url aUrl, org.refcodes.web.RequestHeaderFields aHeaderFields, Object aRequest, org.refcodes.web.MediaTypeFactoryLookup aMediaTypeFactoryLookup)
    Instantiates a new RestResponseResult.
    RestResponseResult(org.refcodes.web.MediaTypeFactoryLookup aMediaTypeFactoryLookup)
    Instantiates a new RestResponseResult.
  • Method Summary

    Modifier and Type
    Method
    Description
    build(RestClient aRestClient)
    This is a convenience method for easily instantiating the according builder.
    void
    org.refcodes.component.ConnectionStatus
    org.refcodes.web.HttpMethod
    org.refcodes.web.FormFields
    This method retrieves the received RestResponse.
    Returns the expected RestResponse result, if none result is available it blocks until one is available (or this instance is notified via Object.notifyAll() or one of the close() methods).
    org.refcodes.web.Url
    boolean
    Tests whether there is already a HTTP-Response
    void
    The invoker provides a response context being a RestResponseEvent describing the response being processed upon by your lambda's code.
    void
    void
    setHeaderFields(org.refcodes.web.RequestHeaderFields aHeaderFields)
    void
    setHttpMethod(org.refcodes.web.HttpMethod aHttpMethod)
    void
    setQueryFields(org.refcodes.web.FormFields aQueryFields)
    void
    setUrl(org.refcodes.web.Url aUrl)
    withCloseIn(int aCloseMillis)
    withHeaderFields(org.refcodes.web.RequestHeaderFields aRequestHeaderFields)
    withHttpMethod(org.refcodes.web.HttpMethod aHttpMethod)
    withRedirectDepth(int aRedirectDepth)
    withRequest(REQ aRequest)
    Sets the request for the request property.
    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 class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.refcodes.component.Closable

    closeIn, closeQuietly, closeUnchecked

    Methods inherited from interface org.refcodes.component.Closable.CloseBuilder

    withCloseUnchecked

    Methods inherited from interface org.refcodes.component.ConnectionStatusAccessor

    isOpened

    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.io.IOResultAccessor

    waitForResult

    Methods inherited from interface org.refcodes.component.Openable

    openUnchecked

    Methods inherited from interface org.refcodes.component.Openable.OpenBuilder

    withOpenUnchecked

    Methods inherited from interface org.refcodes.web.QueryFieldsAccessor.QueryFieldsProperty

    letQueryFields

    Methods inherited from interface org.refcodes.web.RedirectDepthAccessor.RedirectDepthProperty

    letRedirectDepth

    Methods inherited from interface org.refcodes.mixin.ResultAccessor

    waitForResult
  • Constructor Details

    • RestResponseResult

      public RestResponseResult(org.refcodes.web.HttpMethod aHttpMethod, org.refcodes.web.Url aUrl, Object aRequest, int aRedirectDepth, org.refcodes.web.MediaTypeFactoryLookup aMediaTypeFactoryLookup)
      Instantiates a new RestResponseResult.
      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.
      aMediaTypeFactoryLookup - the media type factory lookup
    • RestResponseResult

      public RestResponseResult(org.refcodes.web.HttpMethod aHttpMethod, org.refcodes.web.Url aUrl, Object aRequest, org.refcodes.web.MediaTypeFactoryLookup aMediaTypeFactoryLookup)
      Instantiates a new RestResponseResult.
      Parameters:
      aHttpMethod - the http method
      aUrl - The Url from which to take the URL specific data.
      aRequest - the request
      aMediaTypeFactoryLookup - the media type factory lookup
    • RestResponseResult

      public RestResponseResult(org.refcodes.web.HttpMethod aHttpMethod, org.refcodes.web.Url aUrl, org.refcodes.web.RequestHeaderFields aHeaderFields, Object aRequest, int aRedirectDepth, org.refcodes.web.MediaTypeFactoryLookup aMediaTypeFactoryLookup)
      Instantiates a new RestResponseResult.
      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.
      aMediaTypeFactoryLookup - the media type factory lookup
    • RestResponseResult

      public RestResponseResult(org.refcodes.web.HttpMethod aHttpMethod, org.refcodes.web.Url aUrl, org.refcodes.web.RequestHeaderFields aHeaderFields, Object aRequest, org.refcodes.web.MediaTypeFactoryLookup aMediaTypeFactoryLookup)
      Instantiates a new RestResponseResult.
      Parameters:
      aHttpMethod - the http method
      aUrl - The Url from which to take the URL specific data.
      aHeaderFields - the Header-Fields
      aRequest - the request
      aMediaTypeFactoryLookup - the media type factory lookup
    • RestResponseResult

      public RestResponseResult(org.refcodes.web.HttpMethod aHttpMethod, org.refcodes.web.Url aUrl, int aRedirectDepth, org.refcodes.web.MediaTypeFactoryLookup aMediaTypeFactoryLookup)
      Instantiates a new RestResponseResult.
      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.
      aMediaTypeFactoryLookup - the media type factory lookup
    • RestResponseResult

      public RestResponseResult(org.refcodes.web.HttpMethod aHttpMethod, org.refcodes.web.Url aUrl, org.refcodes.web.MediaTypeFactoryLookup aMediaTypeFactoryLookup)
      Instantiates a new RestResponseResult.
      Parameters:
      aHttpMethod - the http method
      aUrl - The Url from which to take the URL specific data.
      aMediaTypeFactoryLookup - the media type factory lookup
    • RestResponseResult

      public RestResponseResult(org.refcodes.web.MediaTypeFactoryLookup aMediaTypeFactoryLookup)
      Instantiates a new RestResponseResult.
      Parameters:
      aMediaTypeFactoryLookup - the media type factory lookup
  • Method Details

    • getResult

      public RestResponse getResult() throws InterruptedException
      Returns the expected RestResponse result, if none result is available it blocks until one is available (or this instance is notified via Object.notifyAll() or one of the close() methods). To test for a result, call hasResult(). The method getResult() does not block and returns null if there is no result available yet.
      Specified by:
      getResult in interface org.refcodes.mixin.ResultAccessor<RestResponse,InterruptedException>
      Returns:
      The RestResponse as soon as it is available.
      Throws:
      InterruptedException - thrown in case this blocking method is interrupted by invoking Object.notifyAll().
    • getResponse

      public RestResponse getResponse()
      This method retrieves the received RestResponse. It does not block and returns null if there is no result available yet. To block till a result is available, please call getResult().
      Specified by:
      getResponse in interface org.refcodes.mixin.ResponseAccessor<RestResponse>
    • getHttpMethod

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

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

      public void open() throws IOException
      Specified by:
      open in interface org.refcodes.component.Openable
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface org.refcodes.component.Closable
      Throws:
      IOException
    • getConnectionStatus

      public org.refcodes.component.ConnectionStatus getConnectionStatus()
      Specified by:
      getConnectionStatus in interface org.refcodes.component.ConnectionStatusAccessor
    • setHeaderFields

      public void setHeaderFields(org.refcodes.web.RequestHeaderFields aHeaderFields)
      Specified by:
      setHeaderFields in interface org.refcodes.web.HeaderFieldsAccessor.HeaderFieldsMutator<org.refcodes.web.RequestHeaderFields>
    • getUrl

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

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

      public boolean hasResult()
      Tests whether there is already a HTTP-Response
      Specified by:
      hasResult in interface org.refcodes.mixin.ResultAccessor<RestResponse,InterruptedException>
      Returns:
      True in case there is a HTTP-Response, else false.
    • setQueryFields

      public void setQueryFields(org.refcodes.web.FormFields aQueryFields)
      Specified by:
      setQueryFields in interface org.refcodes.web.QueryFieldsAccessor.QueryFieldsMutator
    • getQueryFields

      public org.refcodes.web.FormFields getQueryFields()
      Specified by:
      getQueryFields in interface org.refcodes.web.QueryFieldsAccessor
    • withUrl

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

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

      public <REQ> RestResponseResult 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 RestResponseResult withHeaderFields(org.refcodes.web.RequestHeaderFields aRequestHeaderFields)
      Specified by:
      withHeaderFields in interface org.refcodes.web.HeaderFieldsAccessor.HeaderFieldsBuilder<org.refcodes.web.RequestHeaderFields,RestResponseResult>
    • withRedirectDepth

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

      public RestResponseResult withOpen() throws IOException
      Specified by:
      withOpen in interface org.refcodes.component.Openable.OpenBuilder<org.refcodes.component.LinkComponent.LinkComponentBuilder<RestResponseResult>>
      Throws:
      IOException
    • withClose

      public RestResponseResult withClose() throws IOException
      Specified by:
      withClose in interface org.refcodes.component.Closable.CloseBuilder<org.refcodes.component.LinkComponent.LinkComponentBuilder<RestResponseResult>>
      Throws:
      IOException
    • withCloseQuietly

      public RestResponseResult withCloseQuietly()
      Specified by:
      withCloseQuietly in interface org.refcodes.component.Closable.CloseBuilder<org.refcodes.component.LinkComponent.LinkComponentBuilder<RestResponseResult>>
    • withCloseIn

      public RestResponseResult withCloseIn(int aCloseMillis)
      Specified by:
      withCloseIn in interface org.refcodes.component.Closable.CloseBuilder<org.refcodes.component.LinkComponent.LinkComponentBuilder<RestResponseResult>>
    • build

      public RestResponseResult build(RestClient aRestClient)
      This is a convenience method for easily instantiating the according builder.
      Parameters:
      aRestClient - the rest client to take care of the caller.
      Returns:
      an instance (using a public implementation) of this builder
    • toString

      public String toString()
      Overrides:
      toString in class org.refcodes.web.HttpClientRequest
    • onResponse

      public void onResponse(RestResponseEvent aResponse) throws org.refcodes.web.HttpResponseException
      The invoker provides a response context being a RestResponseEvent describing the response being processed upon by your lambda's code. The method works synchronously and waits (blocks the caller's thread) till it finishes execution.
      Specified by:
      onResponse in interface RestResponseConsumer
      Parameters:
      aResponse - The response of type RestResponseEvent describing the response context. Use HttpClientResponse.getResponse(Class) to retrieve the server's response body or AbstractHttpResponse.getHttpStatusCode() to retrieve the respone's HTTP Status-Code.
      Throws:
      org.refcodes.web.HttpResponseException - thrown by a HTTP-Response handling system in case of some unexpected response.