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(java.time.Instant date)
Set the time the resource was last changed, as specified by the
Last-Modified header. |
ResponseEntity.BodyBuilder |
lastModified(long date)
Set the time the resource was last changed, as specified by the
Last-Modified header. |
ResponseEntity.BodyBuilder |
lastModified(java.time.ZonedDateTime 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.HeadersBuilderheader 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.HeadersBuilderheaders in interface ResponseEntity.HeadersBuilder<ResponseEntity.BodyBuilder>headers - the existing HttpHeaders to copy fromHttpHeaders.add(String, String)public ResponseEntity.BodyBuilder allow(HttpMethod... allowedMethods)
ResponseEntity.HeadersBuilderHTTP 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.BodyBuilderContent-Length header.contentLength in interface ResponseEntity.BodyBuildercontentLength - the content lengthHttpHeaders.setContentLength(long)public ResponseEntity.BodyBuilder contentType(MediaType contentType)
ResponseEntity.BodyBuilderContent-Type header.contentType in interface ResponseEntity.BodyBuildercontentType - the content typeHttpHeaders.setContentType(MediaType)public ResponseEntity.BodyBuilder eTag(java.lang.String etag)
ResponseEntity.HeadersBuilderETag header.eTag in interface ResponseEntity.HeadersBuilder<ResponseEntity.BodyBuilder>etag - the new entity tagHttpHeaders.setETag(String)public ResponseEntity.BodyBuilder lastModified(java.time.ZonedDateTime date)
ResponseEntity.HeadersBuilderLast-Modified header.lastModified in interface ResponseEntity.HeadersBuilder<ResponseEntity.BodyBuilder>date - the last modified dateHttpHeaders.setLastModified(ZonedDateTime)public ResponseEntity.BodyBuilder lastModified(java.time.Instant date)
ResponseEntity.HeadersBuilderLast-Modified header.lastModified in interface ResponseEntity.HeadersBuilder<ResponseEntity.BodyBuilder>date - the last modified dateHttpHeaders.setLastModified(Instant)public ResponseEntity.BodyBuilder lastModified(long date)
ResponseEntity.HeadersBuilderLast-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.HeadersBuilderLocation header.location in interface ResponseEntity.HeadersBuilder<ResponseEntity.BodyBuilder>location - the locationHttpHeaders.setLocation(URI)public ResponseEntity.BodyBuilder cacheControl(CacheControl cacheControl)
ResponseEntity.HeadersBuilderCache-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.HeadersBuildervaryBy in interface ResponseEntity.HeadersBuilder<ResponseEntity.BodyBuilder>requestHeaders - request header namespublic <T> ResponseEntity<T> build()
ResponseEntity.HeadersBuilderbuild in interface ResponseEntity.HeadersBuilder<ResponseEntity.BodyBuilder>ResponseEntity.BodyBuilder.body(Object)public <T> ResponseEntity<T> body(@Nullable T body)
ResponseEntity.BodyBuilderbody in interface ResponseEntity.BodyBuilderT - the type of the bodybody - the body of the response entity