class DefaultRenderingResponseBuilder extends java.lang.Object implements RenderingResponse.Builder
RenderingResponse.Builder
implementation.Modifier and Type | Class and Description |
---|---|
private static class |
DefaultRenderingResponseBuilder.DefaultRenderingResponse |
Modifier and Type | Field and Description |
---|---|
private MultiValueMap<java.lang.String,ResponseCookie> |
cookies |
private HttpHeaders |
headers |
private java.util.Map<java.lang.String,java.lang.Object> |
model |
private java.lang.String |
name |
private int |
status |
Constructor and Description |
---|
DefaultRenderingResponseBuilder(RenderingResponse other) |
DefaultRenderingResponseBuilder(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
<any> |
build()
Build the response.
|
RenderingResponse.Builder |
cookie(ResponseCookie cookie)
Add the given cookie to the response.
|
RenderingResponse.Builder |
cookies(java.util.function.Consumer<MultiValueMap<java.lang.String,ResponseCookie>> cookiesConsumer)
Manipulate this response's cookies with the given consumer.
|
RenderingResponse.Builder |
header(java.lang.String headerName,
java.lang.String... headerValues)
Add the given header value(s) under the given name.
|
RenderingResponse.Builder |
headers(HttpHeaders headers)
Copy the given headers into the entity's headers map.
|
RenderingResponse.Builder |
modelAttribute(java.lang.Object attribute)
Add the supplied attribute to the model using a
generated name.
|
RenderingResponse.Builder |
modelAttribute(java.lang.String name,
java.lang.Object value)
Add the supplied attribute value under the supplied name.
|
RenderingResponse.Builder |
modelAttributes(java.util.Collection<?> attributes)
Copy all attributes in the supplied
Collection into the model,
using attribute name generation for each element. |
RenderingResponse.Builder |
modelAttributes(java.util.Map<java.lang.String,?> attributes)
Copy all attributes in the supplied
Map into the model. |
RenderingResponse.Builder |
modelAttributes(java.lang.Object... attributes)
Copy all attributes in the supplied array into the model,
using attribute name generation for each element.
|
RenderingResponse.Builder |
status(HttpStatus status)
Set the HTTP status.
|
RenderingResponse.Builder |
status(int status)
Set the HTTP status.
|
private final java.lang.String name
private int status
private final HttpHeaders headers
private final MultiValueMap<java.lang.String,ResponseCookie> cookies
private final java.util.Map<java.lang.String,java.lang.Object> model
public DefaultRenderingResponseBuilder(RenderingResponse other)
public DefaultRenderingResponseBuilder(java.lang.String name)
public RenderingResponse.Builder status(HttpStatus status)
RenderingResponse.Builder
status
in interface RenderingResponse.Builder
status
- the response statuspublic RenderingResponse.Builder status(int status)
RenderingResponse.Builder
status
in interface RenderingResponse.Builder
status
- the response statuspublic RenderingResponse.Builder cookie(ResponseCookie cookie)
RenderingResponse.Builder
cookie
in interface RenderingResponse.Builder
cookie
- the cookie to addpublic RenderingResponse.Builder cookies(java.util.function.Consumer<MultiValueMap<java.lang.String,ResponseCookie>> cookiesConsumer)
RenderingResponse.Builder
MultiValueMap
methods.cookies
in interface RenderingResponse.Builder
cookiesConsumer
- a function that consumes the cookiespublic RenderingResponse.Builder modelAttribute(java.lang.Object attribute)
RenderingResponse.Builder
Collections
are not added to
the model when using this method because we cannot correctly determine
the true convention name. View code should check for null
rather
than for empty collections.
modelAttribute
in interface RenderingResponse.Builder
attribute
- the model attribute value (never null
)public RenderingResponse.Builder modelAttribute(java.lang.String name, @Nullable java.lang.Object value)
RenderingResponse.Builder
modelAttribute
in interface RenderingResponse.Builder
name
- the name of the model attribute (never null
)value
- the model attribute value (can be null
)public RenderingResponse.Builder modelAttributes(java.lang.Object... attributes)
RenderingResponse.Builder
modelAttributes
in interface RenderingResponse.Builder
RenderingResponse.Builder.modelAttribute(Object)
public RenderingResponse.Builder modelAttributes(java.util.Collection<?> attributes)
RenderingResponse.Builder
Collection
into the model,
using attribute name generation for each element.modelAttributes
in interface RenderingResponse.Builder
RenderingResponse.Builder.modelAttribute(Object)
public RenderingResponse.Builder modelAttributes(java.util.Map<java.lang.String,?> attributes)
RenderingResponse.Builder
Map
into the model.modelAttributes
in interface RenderingResponse.Builder
RenderingResponse.Builder.modelAttribute(String, Object)
public RenderingResponse.Builder header(java.lang.String headerName, java.lang.String... headerValues)
RenderingResponse.Builder
header
in interface RenderingResponse.Builder
headerName
- the header nameheaderValues
- the header value(s)HttpHeaders.add(String, String)
public RenderingResponse.Builder headers(HttpHeaders headers)
RenderingResponse.Builder
headers
in interface RenderingResponse.Builder
headers
- the existing HttpHeaders to copy fromHttpHeaders.add(String, String)
public <any> build()
RenderingResponse.Builder
build
in interface RenderingResponse.Builder