com.holonplatform.http.internal

## Class DefaultHttpResponse<T>

- java.lang.Object
- - com.holonplatform.http.internal.DefaultHttpResponse<T>

- Type Parameters:
    `T` - Response payload type
  All Implemented Interfaces:
    Message<T,List<String>>, MessageHeaders<List<String>>, HttpHeaders, HttpMessage<T>, HttpResponse<T>

      public class DefaultHttpResponse<T>
      extends Object
      implements HttpResponse<T>

  Default `HttpResponse` implementation.
  Since:
    5.0.0

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `DefaultHttpResponse.DefaultBuilder<T>` Response builder.

    - ### Nested classes/interfaces inherited from interface com.holonplatform.http.HttpResponse

      `HttpResponse.Builder<T>`

  - ### Field Summary

    - ### Fields inherited from interface com.holonplatform.http.HttpHeaders

      `ACCEPT, ACCEPT_CHARSET, ACCEPT_ENCODING, ACCEPT_LANGUAGE, ACCEPT_RANGES, AGE, ALLOW, AUTHORIZATION, CACHE_CONTROL, CONNECTION, CONTENT_DISPOSITION, CONTENT_ENCODING, CONTENT_LANGUAGE, CONTENT_LENGTH, CONTENT_LOCATION, CONTENT_RANGE, CONTENT_TYPE, COOKIE, DATE, ETAG, EXPECT, EXPIRES, FROM, HOST, IF_MATCH, IF_MODIFIED_SINCE, IF_NONE_MATCH, IF_RANGE, IF_UNMODIFIED_SINCE, LAST_MODIFIED, LINK, LOCATION, MAX_FORWARDS, ORIGIN, PRAGMA, PROXY_AUTHENTICATE, PROXY_AUTHORIZATION, RANGE, REFERER, RETRY_AFTER, SCHEME_BASIC, SCHEME_BEARER, SCHEME_DIGEST, SERVER, SET_COOKIE, TRAILER, TRANSFER_ENCODING, UPGRADE, USER_AGENT, VARY, VIA, WARNING, WWW_AUTHENTICATE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultHttpResponse(int statusCode, Class<? extends T> payloadType)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Map<String,List<String>>` | `getHeaders()` Get message headers.
    `Optional<T>` | `getPayload()` Message payload
    `Class<? extends T>` | `getPayloadType()` Message payload type
    `int` | `getStatusCode()` Get the response status code
    `void` | `setHeaders(Map<String,List<String>> headers)` Set response headers.
    `void` | `setHeaderValue(String name, String value)` Set a response header value.
    `void` | `setHeaderValues(String name, List<String> values)` Set a response header with given values.
    `void` | `setPayload(T payload)` Set response payload
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface com.holonplatform.http.HttpResponse

      `builder, builder, getStatus`

    - ### Methods inherited from interface com.holonplatform.http.HttpMessage

      `getProtocol`

    - ### Methods inherited from interface com.holonplatform.http.HttpHeaders

      `getAuthorizationBasicCredentials, getAuthorizationBearer, getContentLength, getDate, getHeaderValue, getLocale, getLocales, getLocation`

    - ### Methods inherited from interface com.holonplatform.core.messaging.MessageHeaders

      `getHeader`

- - ### Constructor Detail

    - #### DefaultHttpResponse

          public DefaultHttpResponse(int statusCode,
                                     Class<? extends T> payloadType)

      Constructor
      Parameters:
        `statusCode` - Response status code
        `payloadType` - Payload type

  - ### Method Detail

    - #### getStatusCode

          public int getStatusCode()

      Description copied from interface: `HttpResponse`
      Get the response status code
      Specified by:
        `getStatusCode` in interface `HttpResponse<T>`
      Returns:
        the response status code

    - #### getHeaders

          public Map<String,List<String>> getHeaders()

      Description copied from interface: `MessageHeaders`
      Get message headers. This method should never return `null`.
      Specified by:
        `getHeaders` in interface `MessageHeaders<List<String>>`
      Returns:
        Message headers, or an empty map if message has no headers

    - #### getPayloadType

          public Class<? extends T> getPayloadType()
                                            throws UnsupportedOperationException

      Description copied from interface: `Message`
      Message payload type
      Specified by:
        `getPayloadType` in interface `Message<T,List<String>>`
      Returns:
        Payload type
      Throws:
        `UnsupportedOperationException` - If this kind of message does not support a payload

    - #### getPayload

          public Optional<T> getPayload()
                                 throws UnsupportedOperationException

      Description copied from interface: `Message`
      Message payload
      Specified by:
        `getPayload` in interface `Message<T,List<String>>`
      Returns:
        Optional message payload
      Throws:
        `UnsupportedOperationException` - If this kind of message does not support a payload

    - #### setHeaders

          public void setHeaders(Map<String,List<String>> headers)

      Set response headers. Any previously set header value will be replaced by the new ones.
      Parameters:
        `headers` - The headers to set as a name - values map

    - #### setHeaderValues

          public void setHeaderValues(String name,
                                      List<String> values)

      Set a response header with given values.
      Parameters:
        `name` - Header name (not null)
        `values` - Header values

    - #### setHeaderValue

          public void setHeaderValue(String name,
                                     String value)

      Set a response header value.
      Parameters:
        `name` - Header name (not null)
        `value` - Header value

    - #### setPayload

          public void setPayload(T payload)

      Set response payload
      Parameters:
        `payload` - the payload to set

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2019 The Holon Platform. All rights reserved.