private static class ResponseEntity.DefaultBuilder extends java.lang.Object implements ResponseEntity.BodyBuilder
Modifier and Type | Field and Description |
---|---|
private HttpHeaders |
headers |
private HttpStatus |
status |
Constructor and Description |
---|
DefaultBuilder(HttpStatus status) |
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.
|
ResponseEntity<java.lang.Void> |
build()
Build the response entity with no body.
|
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. |
private final HttpStatus status
private final HttpHeaders headers
public DefaultBuilder(HttpStatus status)
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(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<java.lang.Void> build()
ResponseEntity.HeadersBuilder
build
in interface ResponseEntity.HeadersBuilder<ResponseEntity.BodyBuilder>
ResponseEntity.BodyBuilder.body(Object)
public <T> ResponseEntity<T> body(T body)
ResponseEntity.BodyBuilder
body
in interface ResponseEntity.BodyBuilder
T
- the type of the bodybody
- the body of the response entity