private static class ResponseEntity.DefaultBuilder extends java.lang.Object implements ResponseEntity.BodyBuilder
Modifier and Type | Field and Description |
---|---|
private HttpHeaders |
headers |
private java.lang.Object |
statusCode |
Constructor and Description |
---|
DefaultBuilder(java.lang.Object statusCode) |
Modifier and Type | Method and Description |
---|---|
ResponseEntity.BodyBuilder |
allow(HttpMethod... allowedMethods)
Set the set of allowed
HTTP methods , as specified
by the Allow header. |
<T> ResponseEntity<T> |
body(T body)
Set the body of the response entity and returns it.
|
<T> ResponseEntity<T> |
build()
Build the response entity with no body.
|
ResponseEntity.BodyBuilder |
cacheControl(CacheControl cacheControl)
Set the caching directives for the resource, as specified by the HTTP 1.1
Cache-Control header. |
ResponseEntity.BodyBuilder |
contentLength(long contentLength)
Set the length of the body in bytes, as specified by the
Content-Length header. |
ResponseEntity.BodyBuilder |
contentType(MediaType contentType)
Set the media type of the body, as specified by the
Content-Type header. |
ResponseEntity.BodyBuilder |
eTag(java.lang.String etag)
Set the entity tag of the body, as specified by the
ETag header. |
ResponseEntity.BodyBuilder |
header(java.lang.String headerName,
java.lang.String... headerValues)
Add the given, single header value under the given name.
|
ResponseEntity.BodyBuilder |
headers(HttpHeaders headers)
Copy the given headers into the entity's headers map.
|
ResponseEntity.BodyBuilder |
lastModified(long date)
Set the time the resource was last changed, as specified by the
Last-Modified header. |
ResponseEntity.BodyBuilder |
location(java.net.URI location)
Set the location of a resource, as specified by the
Location header. |
ResponseEntity.BodyBuilder |
varyBy(java.lang.String... requestHeaders)
Configure one or more request header names (e.g.
|
private final java.lang.Object statusCode
private final HttpHeaders headers
public ResponseEntity.BodyBuilder header(java.lang.String headerName, java.lang.String... headerValues)
ResponseEntity.HeadersBuilder
header
in interface ResponseEntity.HeadersBuilder<ResponseEntity.BodyBuilder>
headerName
- the header nameheaderValues
- the header value(s)HttpHeaders.add(String, String)
public ResponseEntity.BodyBuilder headers(@Nullable HttpHeaders headers)
ResponseEntity.HeadersBuilder
headers
in interface ResponseEntity.HeadersBuilder<ResponseEntity.BodyBuilder>
headers
- the existing HttpHeaders to copy fromHttpHeaders.add(String, String)
public ResponseEntity.BodyBuilder allow(HttpMethod... allowedMethods)
ResponseEntity.HeadersBuilder
HTTP methods
, as specified
by the Allow
header.allow
in interface ResponseEntity.HeadersBuilder<ResponseEntity.BodyBuilder>
allowedMethods
- the allowed methodsHttpHeaders.setAllow(Set)
public ResponseEntity.BodyBuilder contentLength(long contentLength)
ResponseEntity.BodyBuilder
Content-Length
header.contentLength
in interface ResponseEntity.BodyBuilder
contentLength
- the content lengthHttpHeaders.setContentLength(long)
public ResponseEntity.BodyBuilder contentType(MediaType contentType)
ResponseEntity.BodyBuilder
Content-Type
header.contentType
in interface ResponseEntity.BodyBuilder
contentType
- the content typeHttpHeaders.setContentType(MediaType)
public ResponseEntity.BodyBuilder eTag(java.lang.String etag)
ResponseEntity.HeadersBuilder
ETag
header.eTag
in interface ResponseEntity.HeadersBuilder<ResponseEntity.BodyBuilder>
etag
- the new entity tagHttpHeaders.setETag(String)
public ResponseEntity.BodyBuilder lastModified(long date)
ResponseEntity.HeadersBuilder
Last-Modified
header.
The date should be specified as the number of milliseconds since January 1, 1970 GMT.
lastModified
in interface ResponseEntity.HeadersBuilder<ResponseEntity.BodyBuilder>
date
- the last modified dateHttpHeaders.setLastModified(long)
public ResponseEntity.BodyBuilder location(java.net.URI location)
ResponseEntity.HeadersBuilder
Location
header.location
in interface ResponseEntity.HeadersBuilder<ResponseEntity.BodyBuilder>
location
- the locationHttpHeaders.setLocation(URI)
public ResponseEntity.BodyBuilder cacheControl(CacheControl cacheControl)
ResponseEntity.HeadersBuilder
Cache-Control
header.
A CacheControl
instance can be built like
CacheControl.maxAge(3600).cachePublic().noTransform()
.
cacheControl
in interface ResponseEntity.HeadersBuilder<ResponseEntity.BodyBuilder>
cacheControl
- a builder for cache-related HTTP response headerspublic ResponseEntity.BodyBuilder varyBy(java.lang.String... requestHeaders)
ResponseEntity.HeadersBuilder
varyBy
in interface ResponseEntity.HeadersBuilder<ResponseEntity.BodyBuilder>
requestHeaders
- request header namespublic <T> ResponseEntity<T> build()
ResponseEntity.HeadersBuilder
build
in interface ResponseEntity.HeadersBuilder<ResponseEntity.BodyBuilder>
ResponseEntity.BodyBuilder.body(Object)
public <T> ResponseEntity<T> body(@Nullable T body)
ResponseEntity.BodyBuilder
body
in interface ResponseEntity.BodyBuilder
T
- the type of the bodybody
- the body of the response entity