Class AbstractRestResponseBuilder<T>
- java.lang.Object
-
- org.jboss.resteasy.reactive.RestResponse.ResponseBuilder<T>
-
- org.jboss.resteasy.reactive.common.jaxrs.AbstractRestResponseBuilder<T>
-
public abstract class AbstractRestResponseBuilder<T> extends RestResponse.ResponseBuilder<T>
-
-
Field Summary
Fields Modifier and Type Field Description protected Object
entity
protected Annotation[]
entityAnnotations
protected MultivaluedTreeMap<String,Object>
metadata
protected String
reasonPhrase
protected int
status
-
Constructor Summary
Constructors Constructor Description AbstractRestResponseBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description RestResponse.ResponseBuilder<T>
allow(String... methods)
Set the list of allowed methods for the resource.RestResponse.ResponseBuilder<T>
allow(Set<String> methods)
Set the list of allowed methods for the resource.RestResponseImpl<T>
build()
Create a RestResponse instance from the current ResponseBuilder.RestResponseImpl<T>
build(boolean copyHeaders)
RestResponse.ResponseBuilder<T>
cacheControl(jakarta.ws.rs.core.CacheControl cacheControl)
Set the cache control data of the message.AbstractRestResponseBuilder<T>
clone()
RestResponse.ResponseBuilder<T>
cookie(jakarta.ws.rs.core.NewCookie... cookies)
Add cookies to the response message.static String
createVaryHeader(List<jakarta.ws.rs.core.Variant> variants)
protected abstract AbstractRestResponseBuilder<T>
doClone()
RestResponse.ResponseBuilder<T>
encoding(String encoding)
Set the message entity content encoding.RestResponse.ResponseBuilder<T>
entity(T entity)
Set the response entity in the builder.RestResponse.ResponseBuilder<T>
entity(T entity, Annotation[] annotations)
Set the response entity in the builder.RestResponse.ResponseBuilder<T>
expires(Date expires)
Set the response expiration date.static SimpleDateFormat
getDateFormatRFC822()
Object
getEntity()
Annotation[]
getEntityAnnotations()
jakarta.ws.rs.core.MultivaluedMap<String,Object>
getMetadata()
String
getReasonPhrase()
int
getStatus()
RestResponse.ResponseBuilder<T>
header(String name, Object value)
Add an arbitrary header.RestResponse.ResponseBuilder<T>
language(String language)
Set the message entity language.RestResponse.ResponseBuilder<T>
language(Locale language)
Set the message entity language.RestResponse.ResponseBuilder<T>
lastModified(Date lastModified)
Set the response entity last modification date.RestResponse.ResponseBuilder<T>
link(String uri, String rel)
Add a link header.RestResponse.ResponseBuilder<T>
link(URI uri, String rel)
Add a link header.RestResponse.ResponseBuilder<T>
links(jakarta.ws.rs.core.Link... links)
Add one or more link headers.<OtherT extends RestResponseImpl<T>>
OtherTpopulateResponse(OtherT response)
Populates a response with the standard data<OtherT extends RestResponseImpl<T>>
OtherTpopulateResponse(OtherT response, boolean copyHeaders)
RestResponse.ResponseBuilder<T>
replaceAll(jakarta.ws.rs.core.MultivaluedMap<String,Object> headers)
Replaces all existing headers with the newly supplied headers.void
setAllHeaders(jakarta.ws.rs.core.MultivaluedMap<String,String> values)
void
setEntityAnnotations(Annotation[] entityAnnotations)
<Ret extends T>
RestResponse.ResponseBuilder<Ret>status(int status)
Set the status on the ResponseBuilder.<Ret extends T>
RestResponse.ResponseBuilder<Ret>status(int status, String reasonPhrase)
Set the status on the ResponseBuilder.RestResponse.ResponseBuilder<T>
tag(jakarta.ws.rs.core.EntityTag tag)
Set a response entity tag.RestResponse.ResponseBuilder<T>
tag(String tag)
Set a strong response entity tag.RestResponse.ResponseBuilder<T>
type(jakarta.ws.rs.core.MediaType type)
Set the message entity media type.RestResponse.ResponseBuilder<T>
type(String type)
Set the message entity media type.RestResponse.ResponseBuilder<T>
variant(jakarta.ws.rs.core.Variant variant)
Set message entity representation metadata.RestResponse.ResponseBuilder<T>
variants(jakarta.ws.rs.core.Variant... variants)
Add a Vary header that lists the available variants.RestResponse.ResponseBuilder<T>
variants(List<jakarta.ws.rs.core.Variant> variants)
Add a Vary header that lists the available variants.-
Methods inherited from class org.jboss.resteasy.reactive.RestResponse.ResponseBuilder
accepted, accepted, contentLocation, create, create, create, create, create, create, created, fromResponse, location, newInstance, noContent, notAcceptable, notFound, notModified, notModified, notModified, ok, ok, ok, ok, ok, seeOther, serverError, status, status, temporaryRedirect
-
-
-
-
Field Detail
-
status
protected int status
-
reasonPhrase
protected String reasonPhrase
-
entity
protected Object entity
-
metadata
protected MultivaluedTreeMap<String,Object> metadata
-
entityAnnotations
protected Annotation[] entityAnnotations
-
-
Method Detail
-
getDateFormatRFC822
public static SimpleDateFormat getDateFormatRFC822()
-
getStatus
public int getStatus()
-
getReasonPhrase
public String getReasonPhrase()
-
getEntity
public Object getEntity()
-
getEntityAnnotations
public Annotation[] getEntityAnnotations()
-
setEntityAnnotations
public void setEntityAnnotations(Annotation[] entityAnnotations)
-
build
public RestResponseImpl<T> build()
Description copied from class:RestResponse.ResponseBuilder
Create a RestResponse instance from the current ResponseBuilder. The builder is reset to a blank state equivalent to calling the ok method.- Specified by:
build
in classRestResponse.ResponseBuilder<T>
- Returns:
- a RestResponse instance.
-
build
public RestResponseImpl<T> build(boolean copyHeaders)
-
populateResponse
public <OtherT extends RestResponseImpl<T>> OtherT populateResponse(OtherT response)
Populates a response with the standard data- Returns:
- The given response
-
populateResponse
public <OtherT extends RestResponseImpl<T>> OtherT populateResponse(OtherT response, boolean copyHeaders)
-
doClone
protected abstract AbstractRestResponseBuilder<T> doClone()
-
clone
public AbstractRestResponseBuilder<T> clone()
Description copied from class:RestResponse.ResponseBuilder
Create a copy of the ResponseBuilder preserving its state.
- Specified by:
clone
in classRestResponse.ResponseBuilder<T>
- Returns:
- a copy of the ResponseBuilder.
-
status
public <Ret extends T> RestResponse.ResponseBuilder<Ret> status(int status, String reasonPhrase)
Description copied from class:RestResponse.ResponseBuilder
Set the status on the ResponseBuilder.- Specified by:
status
in classRestResponse.ResponseBuilder<T>
- Parameters:
status
- the response status.reasonPhrase
- the reason phrase.- Returns:
- the updated response builder.
-
status
public <Ret extends T> RestResponse.ResponseBuilder<Ret> status(int status)
Description copied from class:RestResponse.ResponseBuilder
Set the status on the ResponseBuilder.- Specified by:
status
in classRestResponse.ResponseBuilder<T>
- Parameters:
status
- the response status.- Returns:
- the updated response builder.
-
entity
public RestResponse.ResponseBuilder<T> entity(T entity)
Description copied from class:RestResponse.ResponseBuilder
Set the response entity in the builder. Any Java type instance for a response entity, that is supported by the runtime can be passed. It is the callers responsibility to wrap the actual entity withGenericEntity
if preservation of its generic type is required. Note that the entity can be also set as aninput stream
. A specific entity media type can be set using one of thetype(...)
methods.- Specified by:
entity
in classRestResponse.ResponseBuilder<T>
- Parameters:
entity
- the request entity.- Returns:
- updated response builder instance.
- See Also:
RestResponse.ResponseBuilder.entity(java.lang.Object, java.lang.annotation.Annotation[])
,RestResponse.ResponseBuilder.type(jakarta.ws.rs.core.MediaType)
,RestResponse.ResponseBuilder.type(java.lang.String)
-
entity
public RestResponse.ResponseBuilder<T> entity(T entity, Annotation[] annotations)
Description copied from class:RestResponse.ResponseBuilder
Set the response entity in the builder. Any Java type instance for a response entity, that is supported by the runtime can be passed. It is the callers responsibility to wrap the actual entity withGenericEntity
if preservation of its generic type is required. Note that the entity can be also set as aninput stream
. A specific entity media type can be set using one of thetype(...)
methods.- Specified by:
entity
in classRestResponse.ResponseBuilder<T>
- Parameters:
entity
- the request entity.annotations
- annotations that will be passed to theMessageBodyWriter
, (in addition to any annotations declared directly on a resource method that returns the built response).- Returns:
- updated response builder instance.
- See Also:
RestResponse.ResponseBuilder.entity(java.lang.Object)
,RestResponse.ResponseBuilder.type(jakarta.ws.rs.core.MediaType)
,RestResponse.ResponseBuilder.type(java.lang.String)
-
type
public RestResponse.ResponseBuilder<T> type(jakarta.ws.rs.core.MediaType type)
Description copied from class:RestResponse.ResponseBuilder
Set the message entity media type.- Specified by:
type
in classRestResponse.ResponseBuilder<T>
- Parameters:
type
- the media type of the message entity. Ifnull
, any existing value for type will be removed.- Returns:
- the updated response builder.
-
type
public RestResponse.ResponseBuilder<T> type(String type)
Description copied from class:RestResponse.ResponseBuilder
Set the message entity media type.- Specified by:
type
in classRestResponse.ResponseBuilder<T>
- Parameters:
type
- the media type of the message entity. Ifnull
, any existing value for type will be removed.- Returns:
- the updated response builder.
-
variant
public RestResponse.ResponseBuilder<T> variant(jakarta.ws.rs.core.Variant variant)
Description copied from class:RestResponse.ResponseBuilder
Set message entity representation metadata. Equivalent to setting the values of content type, content language, and content encoding separately using the values of the variant properties.- Specified by:
variant
in classRestResponse.ResponseBuilder<T>
- Parameters:
variant
- metadata of the message entity, anull
value is equivalent to a variant with allnull
properties.- Returns:
- the updated response builder.
- See Also:
RestResponse.ResponseBuilder.encoding(java.lang.String)
,RestResponse.ResponseBuilder.language(java.util.Locale)
,RestResponse.ResponseBuilder.type(jakarta.ws.rs.core.MediaType)
-
variants
public RestResponse.ResponseBuilder<T> variants(List<jakarta.ws.rs.core.Variant> variants)
Description copied from class:RestResponse.ResponseBuilder
Add a Vary header that lists the available variants.- Specified by:
variants
in classRestResponse.ResponseBuilder<T>
- Parameters:
variants
- a list of available representation variants, anull
value will remove an existing value for Vary header.- Returns:
- the updated response builder.
-
language
public RestResponse.ResponseBuilder<T> language(String language)
Description copied from class:RestResponse.ResponseBuilder
Set the message entity language.- Specified by:
language
in classRestResponse.ResponseBuilder<T>
- Parameters:
language
- the language of the message entity, ifnull
any existing value for language will be removed.- Returns:
- the updated response builder.
-
tag
public RestResponse.ResponseBuilder<T> tag(jakarta.ws.rs.core.EntityTag tag)
Description copied from class:RestResponse.ResponseBuilder
Set a response entity tag.- Specified by:
tag
in classRestResponse.ResponseBuilder<T>
- Parameters:
tag
- the entity tag, ifnull
any existing entity tag value will be removed.- Returns:
- the updated response builder.
-
tag
public RestResponse.ResponseBuilder<T> tag(String tag)
Description copied from class:RestResponse.ResponseBuilder
Set a strong response entity tag. This is a shortcut fortag(new EntityTag(value))
.- Specified by:
tag
in classRestResponse.ResponseBuilder<T>
- Parameters:
tag
- the string content of a strong entity tag. The runtime will quote the supplied value when creating the header. Ifnull
any existing entity tag value will be removed.- Returns:
- the updated response builder.
-
lastModified
public RestResponse.ResponseBuilder<T> lastModified(Date lastModified)
Description copied from class:RestResponse.ResponseBuilder
Set the response entity last modification date.- Specified by:
lastModified
in classRestResponse.ResponseBuilder<T>
- Parameters:
lastModified
- the last modified date, ifnull
any existing last modified value will be removed.- Returns:
- the updated response builder.
-
cacheControl
public RestResponse.ResponseBuilder<T> cacheControl(jakarta.ws.rs.core.CacheControl cacheControl)
Description copied from class:RestResponse.ResponseBuilder
Set the cache control data of the message.- Specified by:
cacheControl
in classRestResponse.ResponseBuilder<T>
- Parameters:
cacheControl
- the cache control directives, ifnull
any existing cache control directives will be removed.- Returns:
- the updated response builder.
-
header
public RestResponse.ResponseBuilder<T> header(String name, Object value)
Description copied from class:RestResponse.ResponseBuilder
Add an arbitrary header.- Specified by:
header
in classRestResponse.ResponseBuilder<T>
- Parameters:
name
- the name of the headervalue
- the value of the header, the header will be serialized using aRuntimeDelegate.HeaderDelegate
if one is available viaRuntimeDelegate.createHeaderDelegate(java.lang.Class)
for the class ofvalue
or using itstoString
method if a header delegate is not available. Ifvalue
isnull
then all current headers of the same name will be removed.- Returns:
- the updated response builder.
-
cookie
public RestResponse.ResponseBuilder<T> cookie(jakarta.ws.rs.core.NewCookie... cookies)
Description copied from class:RestResponse.ResponseBuilder
Add cookies to the response message.- Specified by:
cookie
in classRestResponse.ResponseBuilder<T>
- Parameters:
cookies
- new cookies that will accompany the response. Anull
value will remove all cookies, including those added via theRestResponse.ResponseBuilder.header(java.lang.String, java.lang.Object)
method.- Returns:
- the updated response builder.
-
language
public RestResponse.ResponseBuilder<T> language(Locale language)
Description copied from class:RestResponse.ResponseBuilder
Set the message entity language.- Specified by:
language
in classRestResponse.ResponseBuilder<T>
- Parameters:
language
- the language of the message entity, ifnull
any existing value for type will be removed.- Returns:
- the updated response builder.
-
expires
public RestResponse.ResponseBuilder<T> expires(Date expires)
Description copied from class:RestResponse.ResponseBuilder
Set the response expiration date.- Specified by:
expires
in classRestResponse.ResponseBuilder<T>
- Parameters:
expires
- the expiration date, ifnull
removes any existing expires value.- Returns:
- the updated response builder.
-
allow
public RestResponse.ResponseBuilder<T> allow(String... methods)
Description copied from class:RestResponse.ResponseBuilder
Set the list of allowed methods for the resource. Any duplicate method names will be truncated to a single entry.- Specified by:
allow
in classRestResponse.ResponseBuilder<T>
- Parameters:
methods
- the methods to be listed as allowed for the resource, ifnull
any existing allowed method list will be removed.- Returns:
- the updated response builder.
-
allow
public RestResponse.ResponseBuilder<T> allow(Set<String> methods)
Description copied from class:RestResponse.ResponseBuilder
Set the list of allowed methods for the resource.- Specified by:
allow
in classRestResponse.ResponseBuilder<T>
- Parameters:
methods
- the methods to be listed as allowed for the resource, ifnull
any existing allowed method list will be removed.- Returns:
- the updated response builder.
-
encoding
public RestResponse.ResponseBuilder<T> encoding(String encoding)
Description copied from class:RestResponse.ResponseBuilder
Set the message entity content encoding.- Specified by:
encoding
in classRestResponse.ResponseBuilder<T>
- Parameters:
encoding
- the content encoding of the message entity, ifnull
any existing value for content encoding will be removed.- Returns:
- the updated response builder.
-
variants
public RestResponse.ResponseBuilder<T> variants(jakarta.ws.rs.core.Variant... variants)
Description copied from class:RestResponse.ResponseBuilder
Add a Vary header that lists the available variants.- Specified by:
variants
in classRestResponse.ResponseBuilder<T>
- Parameters:
variants
- a list of available representation variants, anull
value will remove an existing value for Vary header.- Returns:
- the updated response builder.
-
links
public RestResponse.ResponseBuilder<T> links(jakarta.ws.rs.core.Link... links)
Description copied from class:RestResponse.ResponseBuilder
Add one or more link headers.- Specified by:
links
in classRestResponse.ResponseBuilder<T>
- Parameters:
links
- links to be added to the message as headers, anull
value will remove any existing Link headers.- Returns:
- the updated response builder.
-
link
public RestResponse.ResponseBuilder<T> link(URI uri, String rel)
Description copied from class:RestResponse.ResponseBuilder
Add a link header.- Specified by:
link
in classRestResponse.ResponseBuilder<T>
- Parameters:
uri
- underlying URI for link header.rel
- value of "rel" parameter.- Returns:
- the updated response builder.
-
link
public RestResponse.ResponseBuilder<T> link(String uri, String rel)
Description copied from class:RestResponse.ResponseBuilder
Add a link header.- Specified by:
link
in classRestResponse.ResponseBuilder<T>
- Parameters:
uri
- underlying URI for link header.rel
- value of "rel" parameter.- Returns:
- the updated response builder.
-
replaceAll
public RestResponse.ResponseBuilder<T> replaceAll(jakarta.ws.rs.core.MultivaluedMap<String,Object> headers)
Description copied from class:RestResponse.ResponseBuilder
Replaces all existing headers with the newly supplied headers.- Specified by:
replaceAll
in classRestResponse.ResponseBuilder<T>
- Parameters:
headers
- new headers to be set, ifnull
all existing headers will be removed.- Returns:
- the updated response builder.
-
-