Top Description Inners Fields Constructors Methods
org.springframework.web.reactive.function.server

pack-priv Class DefaultEntityResponseBuilder<T>

extends Object
implements EntityResponse.Builder<T>
Class Inheritance
All Implemented Interfaces
org.springframework.web.reactive.function.server.EntityResponse.Builder
Type Parameters
<T>
a self reference to the builder type
Imports
java.net.URI, java.time.Instant, .ZonedDateTime, java.util.Arrays, .HashMap, .LinkedHashSet, .List, .Map, .Optional, .Set, java.util.function.Consumer, reactor.core.publisher.Mono, org.springframework.core.codec.Hints, org.springframework.http.CacheControl, .HttpHeaders, .HttpMethod, .HttpStatus, .HttpStatusCode, .MediaType, .ResponseCookie, org.springframework.http.codec.HttpMessageWriter, org.springframework.http.server.reactive.ServerHttpRequest, .ServerHttpResponse, org.springframework.util.Assert, .LinkedMultiValueMap, .MultiValueMap, org.springframework.web.reactive.function.BodyInserter, org.springframework.web.server.ServerWebExchange

Default EntityResponse.Builder implementation.
Authors
Arjen Poutsma, Juergen Hoeller
Since
5.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final MultiValueMap<String, ResponseCookie>
private final T
private final HttpHeaders
private final Map<String, Object>
private final BodyInserter<T, ? super ServerHttpResponse>
private HttpStatusCode

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public EntityResponse.Builder<T>
allow(HttpMethod...
the allowed methods
allowedMethods
)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.allow.

Set the set of allowed HTTP methods, as specified by the Allow header.

public EntityResponse.Builder<T>
allow(Set<HttpMethod>
the allowed methods
allowedMethods
)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.allow.

Set the set of allowed HTTP methods, as specified by the Allow header.

public Mono<EntityResponse<T>>
public EntityResponse.Builder<T>
cacheControl(CacheControl
a builder for cache-related HTTP response headers
cacheControl
)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.cacheControl.

Set the caching directives for the resource, as specified by the HTTP 1.1 Cache-Control header.

public EntityResponse.Builder<T>
contentLength(long
the content length
contentLength
)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.contentLength.

Set the length of the body in bytes, as specified by the Content-Length header.

public EntityResponse.Builder<T>
contentType(MediaType
the content type
contentType
)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.contentType.

Set the media type of the body, as specified by the Content-Type header.

public EntityResponse.Builder<T>
cookies(Consumer<MultiValueMap<String, ResponseCookie>>
a function that consumes the cookies
cookiesConsumer
)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.cookies.

Manipulate this response's cookies with the given consumer.

public EntityResponse.Builder<T>
eTag(String
the new entity tag
etag
)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.eTag.

Set the entity tag of the body, as specified by the ETag header.

public EntityResponse.Builder<T>
header(String
the header name
headerName
,
String...
the header value(s)
headerValues
)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.header.

Add the given header value(s) under the given name.

public EntityResponse.Builder<T>
headers(HttpHeaders
the existing HttpHeaders to copy from
headers
)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.headers.

Copy the given headers into the entity's headers map.

public EntityResponse.Builder<T>
headers(Consumer<HttpHeaders>
a function that consumes the HttpHeaders
headersConsumer
)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.headers.

Manipulate this entity's headers with the given consumer.

public EntityResponse.Builder<T>
hint(String
the hint key
key
,
Object
the hint value
value
)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.hint.

Add a serialization hint like Jackson2CodecSupport#JSON_VIEW_HINT to customize how the body will be serialized.

public EntityResponse.Builder<T>
hints(Consumer<Map<String, Object>>
a function that consumes the hints
hintsConsumer
)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.hints.

Customize the serialization hints with the given consumer.

public EntityResponse.Builder<T>
lastModified(ZonedDateTime
the last modified date
lastModified
)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.lastModified.

Set the time the resource was last changed, as specified by the Last-Modified header.

public EntityResponse.Builder<T>
lastModified(Instant
the last modified date
lastModified
)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.lastModified.

Set the time the resource was last changed, as specified by the Last-Modified header.

public EntityResponse.Builder<T>
location(URI
the location
location
)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.location.

Set the location of a resource, as specified by the Location header.

public EntityResponse.Builder<T>
public EntityResponse.Builder<T>
status(int
the response status
status
)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.status.

Set the HTTP status.

public EntityResponse.Builder<T>
varyBy(String...
request header names
requestHeaders
)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.varyBy.

Configure one or more request header names (e.g. "Accept-Language") to add to the "Vary" response header to inform clients that the response is subject to content negotiation and variances based on the value of the given request headers.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cookiesback to summary
private final MultiValueMap<String, ResponseCookie> cookies
entityback to summary
private final T entity
headersback to summary
private final HttpHeaders headers
hintsback to summary
private final Map<String, Object> hints
inserterback to summary
private final BodyInserter<T, ? super ServerHttpResponse> inserter
statusback to summary
private HttpStatusCode status

Constructor Detail

DefaultEntityResponseBuilderback to summary
public DefaultEntityResponseBuilder(T entity, BodyInserter<T, ? super ServerHttpResponse> inserter)

Method Detail

allowback to summary
public EntityResponse.Builder<T> allow(HttpMethod... allowedMethods)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.allow.

Doc from org.springframework.web.reactive.function.server.EntityResponse.Builder.allow.

Set the set of allowed HTTP methods, as specified by the Allow header.

Parameters
allowedMethods:HttpMethod[]

the allowed methods

Returns:EntityResponse.Builder<T>

this builder

Annotations
@Override
allowback to summary
public EntityResponse.Builder<T> allow(Set<HttpMethod> allowedMethods)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.allow.

Doc from org.springframework.web.reactive.function.server.EntityResponse.Builder.allow.

Set the set of allowed HTTP methods, as specified by the Allow header.

Parameters
allowedMethods:Set<HttpMethod>

the allowed methods

Returns:EntityResponse.Builder<T>

this builder

Annotations
@Override
buildback to summary
public Mono<EntityResponse<T>> build()

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.build.

Doc from org.springframework.web.reactive.function.server.EntityResponse.Builder.build.

Build the response.

Returns:Mono<EntityResponse<T>>

the built response

Annotations
@Override
cacheControlback to summary
public EntityResponse.Builder<T> cacheControl(CacheControl cacheControl)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.cacheControl.

Doc from org.springframework.web.reactive.function.server.EntityResponse.Builder.cacheControl.

Set the caching directives for the resource, as specified by the HTTP 1.1 Cache-Control header.

A CacheControl instance can be built like CacheControl.maxAge(3600).cachePublic().noTransform().

Parameters
cacheControl:CacheControl

a builder for cache-related HTTP response headers

Returns:EntityResponse.Builder<T>

this builder

Annotations
@Override
contentLengthback to summary
public EntityResponse.Builder<T> contentLength(long contentLength)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.contentLength.

Doc from org.springframework.web.reactive.function.server.EntityResponse.Builder.contentLength.

Set the length of the body in bytes, as specified by the Content-Length header.

Parameters
contentLength:long

the content length

Returns:EntityResponse.Builder<T>

this builder

Annotations
@Override
contentTypeback to summary
public EntityResponse.Builder<T> contentType(MediaType contentType)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.contentType.

Doc from org.springframework.web.reactive.function.server.EntityResponse.Builder.contentType.

Set the media type of the body, as specified by the Content-Type header.

Parameters
contentType:MediaType

the content type

Returns:EntityResponse.Builder<T>

this builder

Annotations
@Override
cookiesback to summary
public EntityResponse.Builder<T> cookies(Consumer<MultiValueMap<String, ResponseCookie>> cookiesConsumer)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.cookies.

Doc from org.springframework.web.reactive.function.server.EntityResponse.Builder.cookies.

Manipulate this response's cookies with the given consumer. The cookies provided to the consumer are "live", so that the consumer can be used to overwrite existing cookies, remove cookies, or use any of the other MultiValueMap methods.

Parameters
cookiesConsumer:Consumer<MultiValueMap<String, ResponseCookie>>

a function that consumes the cookies

Returns:EntityResponse.Builder<T>

this builder

Annotations
@Override
eTagback to summary
public EntityResponse.Builder<T> eTag(String etag)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.eTag.

Doc from org.springframework.web.reactive.function.server.EntityResponse.Builder.eTag.

Set the entity tag of the body, as specified by the ETag header.

Parameters
etag:String

the new entity tag

Returns:EntityResponse.Builder<T>

this builder

Annotations
@Override
headerback to summary
public EntityResponse.Builder<T> header(String headerName, String... headerValues)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.header.

Doc from org.springframework.web.reactive.function.server.EntityResponse.Builder.header.

Add the given header value(s) under the given name.

Parameters
headerName:String

the header name

headerValues:String[]

the header value(s)

Returns:EntityResponse.Builder<T>

this builder

Annotations
@Override
headersback to summary
public EntityResponse.Builder<T> headers(HttpHeaders headers)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.headers.

Doc from org.springframework.web.reactive.function.server.EntityResponse.Builder.headers.

Copy the given headers into the entity's headers map.

Parameters
headers:HttpHeaders

the existing HttpHeaders to copy from

Returns:EntityResponse.Builder<T>

this builder

Annotations
@Override
headersback to summary
public EntityResponse.Builder<T> headers(Consumer<HttpHeaders> headersConsumer)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.headers.

Doc from org.springframework.web.reactive.function.server.EntityResponse.Builder.headers.

Manipulate this entity's headers with the given consumer. The headers provided to the consumer are "live", so that the consumer can be used to overwrite existing header values, remove values, or use any of the other HttpHeaders methods.

Parameters
headersConsumer:Consumer<HttpHeaders>

a function that consumes the HttpHeaders

Returns:EntityResponse.Builder<T>

this builder

Annotations
@Override
hintback to summary
public EntityResponse.Builder<T> hint(String key, Object value)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.hint.

Doc from org.springframework.web.reactive.function.server.EntityResponse.Builder.hint.

Add a serialization hint like Jackson2CodecSupport#JSON_VIEW_HINT to customize how the body will be serialized.

Parameters
key:String

the hint key

value:Object

the hint value

Annotations
@Override
hintsback to summary
public EntityResponse.Builder<T> hints(Consumer<Map<String, Object>> hintsConsumer)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.hints.

Doc from org.springframework.web.reactive.function.server.EntityResponse.Builder.hints.

Customize the serialization hints with the given consumer.

Parameters
hintsConsumer:Consumer<Map<String, Object>>

a function that consumes the hints

Returns:EntityResponse.Builder<T>

this builder

Annotations
@Override
lastModifiedback to summary
public EntityResponse.Builder<T> lastModified(ZonedDateTime lastModified)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.lastModified.

Doc from org.springframework.web.reactive.function.server.EntityResponse.Builder.lastModified.

Set the time the resource was last changed, as specified by the Last-Modified header.

The date should be specified as the number of milliseconds since January 1, 1970 GMT.

Parameters
lastModified:ZonedDateTime

the last modified date

Returns:EntityResponse.Builder<T>

this builder

Annotations
@Override
lastModifiedback to summary
public EntityResponse.Builder<T> lastModified(Instant lastModified)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.lastModified.

Doc from org.springframework.web.reactive.function.server.EntityResponse.Builder.lastModified.

Set the time the resource was last changed, as specified by the Last-Modified header.

The date should be specified as the number of milliseconds since January 1, 1970 GMT.

Parameters
lastModified:Instant

the last modified date

Returns:EntityResponse.Builder<T>

this builder

Annotations
@Override
locationback to summary
public EntityResponse.Builder<T> location(URI location)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.location.

Doc from org.springframework.web.reactive.function.server.EntityResponse.Builder.location.

Set the location of a resource, as specified by the Location header.

Parameters
location:URI

the location

Returns:EntityResponse.Builder<T>

this builder

Annotations
@Override
statusback to summary
public EntityResponse.Builder<T> status(HttpStatusCode status)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.status.

Doc from org.springframework.web.reactive.function.server.EntityResponse.Builder.status.

Set the HTTP status.

Parameters
status:HttpStatusCode

the response status

Returns:EntityResponse.Builder<T>

this builder

Annotations
@Override
statusback to summary
public EntityResponse.Builder<T> status(int status)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.status.

Doc from org.springframework.web.reactive.function.server.EntityResponse.Builder.status.

Set the HTTP status.

Parameters
status:int

the response status

Returns:EntityResponse.Builder<T>

this builder

Annotations
@Override
varyByback to summary
public EntityResponse.Builder<T> varyBy(String... requestHeaders)

Implements org.springframework.web.reactive.function.server.EntityResponse.Builder.varyBy.

Doc from org.springframework.web.reactive.function.server.EntityResponse.Builder.varyBy.

Configure one or more request header names (e.g. "Accept-Language") to add to the "Vary" response header to inform clients that the response is subject to content negotiation and variances based on the value of the given request headers. The configured request header names are added only if not already present in the response "Vary" header.

Parameters
requestHeaders:String[]

request header names

Returns:EntityResponse.Builder<T>

this builder

Annotations
@Override
org.springframework.web.reactive.function.server back to summary

private final Class DefaultEntityResponseBuilder.DefaultEntityResponse<T>

extends AbstractServerResponse
implements EntityResponse<T>
Class Inheritance
All Implemented Interfaces
org.springframework.web.reactive.function.server.EntityResponse, org.springframework.web.reactive.function.server.ServerResponse

Field Summary

Modifier and TypeField and Description
private final T
private final BodyInserter<T, ? super ServerHttpResponse>
Inherited from org.springframework.web.reactive.function.server.DefaultServerResponseBuilder.AbstractServerResponse:
hints

Constructor Summary

AccessConstructor and Description
public
DefaultEntityResponse(HttpStatusCode statusCode, HttpHeaders headers, MultiValueMap<String, ResponseCookie> cookies, T entity, BodyInserter<T, ? super ServerHttpResponse> inserter, Map<String, Object> hints)

Method Summary

Modifier and TypeMethod and Description
public T
entity()

Implements org.springframework.web.reactive.function.server.EntityResponse.entity.

Return the entity that makes up this response.

public BodyInserter<T, ? super ServerHttpResponse>
inserter()

Implements org.springframework.web.reactive.function.server.EntityResponse.inserter.

Return the BodyInserter that writes the entity to the output stream.

protected Mono<Void>
Inherited from org.springframework.web.reactive.function.server.DefaultServerResponseBuilder.AbstractServerResponse:
cookiesheadersrawStatusCodestatusCodewriteTo

Field Detail

entityback to summary
private final T entity
inserterback to summary
private final BodyInserter<T, ? super ServerHttpResponse> inserter

Constructor Detail

DefaultEntityResponseback to summary
public DefaultEntityResponse(HttpStatusCode statusCode, HttpHeaders headers, MultiValueMap<String, ResponseCookie> cookies, T entity, BodyInserter<T, ? super ServerHttpResponse> inserter, Map<String, Object> hints)

Method Detail

entityback to summary
public T entity()

Implements org.springframework.web.reactive.function.server.EntityResponse.entity.

Doc from org.springframework.web.reactive.function.server.EntityResponse.entity.

Return the entity that makes up this response.

Annotations
@Override
inserterback to summary
public BodyInserter<T, ? super ServerHttpResponse> inserter()

Implements org.springframework.web.reactive.function.server.EntityResponse.inserter.

Doc from org.springframework.web.reactive.function.server.EntityResponse.inserter.

Return the BodyInserter that writes the entity to the output stream.

Annotations
@Override
writeToInternalback to summary
protected Mono<Void> writeToInternal(ServerWebExchange exchange, ServerResponse.Context context)

Implements abstract org.springframework.web.reactive.function.server.DefaultServerResponseBuilder.AbstractServerResponse.writeToInternal.

Annotations
@Override