public abstract class GenericResponseBuilder<T> extends Object
GenericResponse
instances.
An initial instance of a builder can be obtained via the static methods of the
GenericResponses
class.
Modifier | Constructor and Description |
---|---|
protected |
GenericResponseBuilder(javax.ws.rs.core.Response.ResponseBuilder rawBuilder)
Creates a new
GenericResponseBuilder that delegates to the underlying
rawBuilder . |
Modifier and Type | Method and Description |
---|---|
GenericResponseBuilder<T> |
allow(Set<String> methods)
Set the list of allowed HTTP methods (e.g.
|
GenericResponseBuilder<T> |
allow(String... methods)
Set the list of allowed HTTP methods (e.g.
|
GenericResponse<T> |
build()
Return a new
GenericResponse instance from the builder. |
protected abstract GenericResponse<T> |
build(T body,
javax.ws.rs.core.Response rawResponse)
|
GenericResponseBuilder<T> |
cacheControl(javax.ws.rs.core.CacheControl cacheControl)
Sets the cache control data of the response.
|
GenericResponseBuilder<T> |
contentLocation(URI location)
Sets the content location.
|
GenericResponseBuilder<T> |
cookie(javax.ws.rs.core.NewCookie... cookies)
Sets the response cookies.
|
GenericResponseBuilder<T> |
encoding(String encoding)
Sets the encoding of the entity body.
|
GenericResponseBuilder<T> |
entity(T entity)
Sets the response entity body on the builder.
|
GenericResponseBuilder<T> |
entity(T entity,
Annotation[] annotations)
Sets the response entity body on the builder.
|
GenericResponseBuilder<T> |
errorEntity(Object errorEntity)
Sets the response error entity body on the builder.
|
GenericResponseBuilder<T> |
errorEntity(Object errorEntity,
Annotation[] annotations)
Sets the response error entity body on the builder.
|
GenericResponseBuilder<T> |
expires(Date expires)
Sets the expiration date for the response.
|
GenericResponseBuilder<T> |
header(String name,
Object value)
Adds a header to the response.
|
GenericResponseBuilder<T> |
language(Locale language)
Sets the response language.
|
GenericResponseBuilder<T> |
language(String language)
Sets the response language.
|
GenericResponseBuilder<T> |
lastModified(Date lastModified)
Sets the response entity last modified date.
|
GenericResponseBuilder<T> |
link(String uri,
String rel)
Adds a link header.
|
GenericResponseBuilder<T> |
link(URI uri,
String rel)
Adds a link header.
|
GenericResponseBuilder<T> |
links(javax.ws.rs.core.Link... links)
Sets the link headers.
|
GenericResponseBuilder<T> |
location(URI location)
Sets the response location.
|
GenericResponseBuilder<T> |
replaceAll(javax.ws.rs.core.MultivaluedMap<String,Object> headers)
Replaces all of the headers with the these headers.
|
GenericResponseBuilder<T> |
status(int status)
Sets the HTTP status code on the builder.
|
GenericResponseBuilder<T> |
status(javax.ws.rs.core.Response.Status status)
Sets the HTTP status code on the builder.
|
GenericResponseBuilder<T> |
status(javax.ws.rs.core.Response.StatusType status)
Sets the HTTP status code on the builder.
|
GenericResponseBuilder<T> |
tag(javax.ws.rs.core.EntityTag tag)
Sets the response entity tag.
|
GenericResponseBuilder<T> |
tag(String tag)
Sets the response entity tag.
|
GenericResponseBuilder<T> |
type(javax.ws.rs.core.MediaType type)
Sets the response entity media type.
|
GenericResponseBuilder<T> |
type(String type)
Sets the response entity media type.
|
GenericResponseBuilder<T> |
variant(javax.ws.rs.core.Variant variant)
Sets the response variant data.
|
GenericResponseBuilder<T> |
variants(List<javax.ws.rs.core.Variant> variants)
Sets the variant list for the
Vary header. |
GenericResponseBuilder<T> |
variants(javax.ws.rs.core.Variant... variants)
Sets the variant list for the
Vary header. |
protected GenericResponseBuilder(javax.ws.rs.core.Response.ResponseBuilder rawBuilder)
GenericResponseBuilder
that delegates to the underlying
rawBuilder
.public GenericResponse<T> build()
GenericResponse
instance from the builder.protected abstract GenericResponse<T> build(T body, javax.ws.rs.core.Response rawResponse)
body
- the entity body to build the GenericResponse
with (may be null)rawResponse
- the underlying raw responsepublic GenericResponseBuilder<T> status(int status)
status
- the HTTP status codepublic GenericResponseBuilder<T> status(javax.ws.rs.core.Response.Status status)
status
- the HTTP status codepublic GenericResponseBuilder<T> status(javax.ws.rs.core.Response.StatusType status)
status
- the HTTP status codepublic GenericResponseBuilder<T> entity(T entity)
A specific media type can be set using the type(...)
methods.
entity
- the response entity bodytype(MediaType)
,
type(String)
public GenericResponseBuilder<T> entity(T entity, Annotation[] annotations)
A specific media type can be set using the type(...)
methods.
entity
- the response entity bodyannotations
- annotations, in addition to the annotations on the resource method returning
the response, to be passed to the MessageBodyWriter
type(MediaType)
,
type(String)
public GenericResponseBuilder<T> errorEntity(Object errorEntity)
A specific media type can be set using the type(...)
methods.
errorEntity
- the response error entity bodytype(MediaType)
,
type(String)
public GenericResponseBuilder<T> errorEntity(Object errorEntity, Annotation[] annotations)
A specific media type can be set using the type(...)
methods.
errorEntity
- the response error entity bodyannotations
- annotations, in addition to the annotations on the resource method returning
the response, to be passed to the MessageBodyWriter
type(MediaType)
,
type(String)
public GenericResponseBuilder<T> allow(String... methods)
methods
- the HTTP methods that will be listed as allowed for the resource, null
will clear listpublic GenericResponseBuilder<T> allow(Set<String> methods)
methods
- the HTTP methods that will be listed as allowed for the resource, null
will clear listpublic GenericResponseBuilder<T> cacheControl(javax.ws.rs.core.CacheControl cacheControl)
cacheControl
- the cache control data, null
will clear any existing cache control
datapublic GenericResponseBuilder<T> encoding(String encoding)
encoding
- the encoding of the entity body, null
will clear the existing encodingpublic GenericResponseBuilder<T> header(String name, Object value)
name
- the header namevalue
- the header value, null
will clear any existing headers for the same nameResponse.ResponseBuilder#header(String, Object)
public GenericResponseBuilder<T> replaceAll(javax.ws.rs.core.MultivaluedMap<String,Object> headers)
headers
- the new headers to be used, null
to remove all existing headerspublic GenericResponseBuilder<T> language(String language)
language
- the language of the response, null
will clear the languagepublic GenericResponseBuilder<T> language(Locale language)
language
- the language of the response, null
will clear the languagepublic GenericResponseBuilder<T> type(javax.ws.rs.core.MediaType type)
type
- the response entity media type, null
will clear the media typepublic GenericResponseBuilder<T> type(String type)
type
- the response entity media type, null
will clear the media typepublic GenericResponseBuilder<T> variant(javax.ws.rs.core.Variant variant)
The variant data includes the content type, language, and encoding.
variant
- the variant data for the response, null
will clear the variant (and
associated values)type(MediaType)
,
language(Locale)
,
encoding(String)
,
Variant
public GenericResponseBuilder<T> contentLocation(URI location)
location
- the content location, null
will clear the content locationpublic GenericResponseBuilder<T> cookie(javax.ws.rs.core.NewCookie... cookies)
cookies
- the cookies for the response, null
will clear the response cookiespublic GenericResponseBuilder<T> expires(Date expires)
expires
- the response expiration date, null
clears the expires datepublic GenericResponseBuilder<T> lastModified(Date lastModified)
lastModified
- the date the response entity was last modified, null
will clear the
last modified datepublic GenericResponseBuilder<T> location(URI location)
location
- the response location, relative URIs will be converted to absolute URIs,
null
will clear the locationpublic GenericResponseBuilder<T> tag(javax.ws.rs.core.EntityTag tag)
tag
- the response entity tag, null
will clear the entity tagpublic GenericResponseBuilder<T> tag(String tag)
tag
- the response entity tag, null
will clear the entity tagpublic GenericResponseBuilder<T> variants(javax.ws.rs.core.Variant... variants)
Vary
header.variants
- the list of variants for the Vary
header, null
will clear the
variants.public GenericResponseBuilder<T> variants(List<javax.ws.rs.core.Variant> variants)
Vary
header.variants
- the list of variants for the Vary
header, null
will clear the
variants.public GenericResponseBuilder<T> links(javax.ws.rs.core.Link... links)
links
- the links to be added to the response headers, null
will clear the link
headerspublic GenericResponseBuilder<T> link(URI uri, String rel)
uri
- the URI of the link headerrel
- the value of the rel
parameterpublic GenericResponseBuilder<T> link(String uri, String rel)
uri
- the URI of the link headerrel
- the value of the rel
parameterCopyright © 2017 Cerner Innovation, Inc.. All rights reserved.