接口 EntityResponse.Builder<T>
- 类型参数:
T- the entity type
- 封闭接口:
- EntityResponse<T>
public static interface EntityResponse.Builder<T>
Defines a builder forEntityResponse.
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 EntityResponse.Builder<T>allow(Set<HttpMethod> allowedMethods)Set the set of allowedHTTP methods, as specified by theAllowheader.EntityResponse.Builder<T>allow(HttpMethod... allowedMethods)Set the set of allowedHTTP methods, as specified by theAllowheader.EntityResponse<T>build()Build the response.EntityResponse.Builder<T>cacheControl(CacheControl cacheControl)Set the caching directives for the resource, as specified by the HTTP 1.1Cache-Controlheader.EntityResponse.Builder<T>contentLength(long contentLength)Set the length of the body in bytes, as specified by theContent-Lengthheader.EntityResponse.Builder<T>contentType(MediaType contentType)Set the media type of the body, as specified by theContent-Typeheader.EntityResponse.Builder<T>cookie(Cookie cookie)Add the given cookie to the response.EntityResponse.Builder<T>cookies(Consumer<MultiValueMap<String,Cookie>> cookiesConsumer)Manipulate this response's cookies with the given consumer.EntityResponse.Builder<T>eTag(String etag)Set the entity tag of the body, as specified by theETagheader.EntityResponse.Builder<T>header(String headerName, String... headerValues)Add the given header value(s) under the given name.EntityResponse.Builder<T>headers(Consumer<HttpHeaders> headersConsumer)Manipulate this response's headers with the given consumer.EntityResponse.Builder<T>lastModified(Instant lastModified)Set the time the resource was last changed, as specified by theLast-Modifiedheader.EntityResponse.Builder<T>lastModified(ZonedDateTime lastModified)Set the time the resource was last changed, as specified by theLast-Modifiedheader.EntityResponse.Builder<T>location(URI location)Set the location of a resource, as specified by theLocationheader.EntityResponse.Builder<T>status(int status)Set the HTTP status.EntityResponse.Builder<T>status(HttpStatus status)Set the HTTP status.EntityResponse.Builder<T>varyBy(String... requestHeaders)Configure one or more request header names (e.g.
方法详细资料
header
EntityResponse.Builder<T> header(String headerName, String... headerValues)
Add the given header value(s) under the given name.- 参数:
headerName- the header nameheaderValues- the header value(s)- 返回:
- this builder
- 另请参阅:
HttpHeaders.add(String, String)
headers
EntityResponse.Builder<T> headers(Consumer<HttpHeaders> headersConsumer)
Manipulate this response'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 otherHttpHeadersmethods.- 参数:
headersConsumer- a function that consumes theHttpHeaders- 返回:
- this builder
status
EntityResponse.Builder<T> status(HttpStatus status)
Set the HTTP status.- 参数:
status- the response status- 返回:
- this builder
status
EntityResponse.Builder<T> status(int status)
Set the HTTP status.- 参数:
status- the response status- 返回:
- this builder
cookie
EntityResponse.Builder<T> cookie(Cookie cookie)
Add the given cookie to the response.- 参数:
cookie- the cookie to add- 返回:
- this builder
cookies
EntityResponse.Builder<T> cookies(Consumer<MultiValueMap<String,Cookie>> cookiesConsumer)
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 otherMultiValueMapmethods.- 参数:
cookiesConsumer- a function that consumes the cookies- 返回:
- this builder
allow
EntityResponse.Builder<T> allow(HttpMethod... allowedMethods)
Set the set of allowedHTTP methods, as specified by theAllowheader.- 参数:
allowedMethods- the allowed methods- 返回:
- this builder
- 另请参阅:
HttpHeaders.setAllow(Set)
allow
EntityResponse.Builder<T> allow(Set<HttpMethod> allowedMethods)
Set the set of allowedHTTP methods, as specified by theAllowheader.- 参数:
allowedMethods- the allowed methods- 返回:
- this builder
- 另请参阅:
HttpHeaders.setAllow(Set)
eTag
EntityResponse.Builder<T> eTag(String etag)
Set the entity tag of the body, as specified by theETagheader.- 参数:
etag- the new entity tag- 返回:
- this builder
- 另请参阅:
HttpHeaders.setETag(String)
lastModified
EntityResponse.Builder<T> lastModified(ZonedDateTime lastModified)
Set the time the resource was last changed, as specified by theLast-Modifiedheader.The date should be specified as the number of milliseconds since January 1, 1970 GMT.
- 参数:
lastModified- the last modified date- 返回:
- this builder
- 另请参阅:
HttpHeaders.setLastModified(long)
lastModified
EntityResponse.Builder<T> lastModified(Instant lastModified)
Set the time the resource was last changed, as specified by theLast-Modifiedheader.The date should be specified as the number of milliseconds since January 1, 1970 GMT.
- 参数:
lastModified- the last modified date- 返回:
- this builder
- 从以下版本开始:
- 5.1.4
- 另请参阅:
HttpHeaders.setLastModified(long)
location
EntityResponse.Builder<T> location(URI location)
Set the location of a resource, as specified by theLocationheader.- 参数:
location- the location- 返回:
- this builder
- 另请参阅:
HttpHeaders.setLocation(URI)
cacheControl
EntityResponse.Builder<T> cacheControl(CacheControl cacheControl)
Set the caching directives for the resource, as specified by the HTTP 1.1Cache-Controlheader.A
CacheControlinstance can be built likeCacheControl.maxAge(3600).cachePublic().noTransform().- 参数:
cacheControl- a builder for cache-related HTTP response headers- 返回:
- this builder
- 另请参阅:
- RFC-7234 Section 5.2
varyBy
EntityResponse.Builder<T> varyBy(String... requestHeaders)
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.- 参数:
requestHeaders- request header names- 返回:
- this builder
contentLength
EntityResponse.Builder<T> contentLength(long contentLength)
Set the length of the body in bytes, as specified by theContent-Lengthheader.- 参数:
contentLength- the content length- 返回:
- this builder
- 另请参阅:
HttpHeaders.setContentLength(long)
contentType
EntityResponse.Builder<T> contentType(MediaType contentType)
Set the media type of the body, as specified by theContent-Typeheader.- 参数:
contentType- the content type- 返回:
- this builder
- 另请参阅:
HttpHeaders.setContentType(MediaType)
build
EntityResponse<T> build()
Build the response.- 返回:
- the built response