public abstract static class Response.ResponseBuilder extends Object
@POST Response addWidget(...) { Widget w = ... URI widgetId = UriBuilder.fromResource(Widget.class)... return Response.created(widgetId).build(); }
Several methods have parameters of type URI, UriBuilder
provides
convenient methods to create such values as does URI.create()
.
Where multiple variants of the same method are provided, the type of
the supplied parameter is retained in the metadata of the built
Response
.
Modifier | Constructor and Description |
---|---|
protected |
Response.ResponseBuilder()
Protected constructor, use one of the static methods of
Response to obtain an instance. |
Modifier and Type | Method and Description |
---|---|
abstract Response |
build()
Create a Response instance from the current ResponseBuilder.
|
abstract Response.ResponseBuilder |
cacheControl(CacheControl cacheControl)
Set the cache control data on the ResponseBuilder.
|
abstract Response.ResponseBuilder |
clone()
Create a copy of the ResponseBuilder preserving its state.
|
abstract Response.ResponseBuilder |
contentLocation(URI location)
Set the content location on the ResponseBuilder.
|
abstract Response.ResponseBuilder |
cookie(NewCookie... cookies)
Add cookies to the ResponseBuilder.
|
abstract Response.ResponseBuilder |
entity(Object entity)
Set the entity on the ResponseBuilder.
|
abstract Response.ResponseBuilder |
expires(Date expires)
Set the expires date on the ResponseBuilder.
|
abstract Response.ResponseBuilder |
header(String name,
Object value)
Add a header to the ResponseBuilder.
|
abstract Response.ResponseBuilder |
language(Locale language)
Set the language on the ResponseBuilder.
|
abstract Response.ResponseBuilder |
language(String language)
Set the language on the ResponseBuilder.
|
abstract Response.ResponseBuilder |
lastModified(Date lastModified)
Set the last modified date on the ResponseBuilder.
|
abstract Response.ResponseBuilder |
location(URI location)
Set the location on the ResponseBuilder.
|
protected static Response.ResponseBuilder |
newInstance()
Create a new builder instance.
|
abstract Response.ResponseBuilder |
status(int status)
Set the status on the ResponseBuilder.
|
Response.ResponseBuilder |
status(Response.Status status)
Set the status on the ResponseBuilder.
|
Response.ResponseBuilder |
status(Response.StatusType status)
Set the status on the ResponseBuilder.
|
abstract Response.ResponseBuilder |
tag(EntityTag tag)
Set an entity tag on the ResponseBuilder.
|
abstract Response.ResponseBuilder |
tag(String tag)
Set a strong entity tag on the ResponseBuilder.
|
abstract Response.ResponseBuilder |
type(MediaType type)
Set the response media type on the ResponseBuilder.
|
abstract Response.ResponseBuilder |
type(String type)
Set the response media type on the ResponseBuilder.
|
abstract Response.ResponseBuilder |
variant(Variant variant)
Set representation metadata on the ResponseBuilder.
|
abstract Response.ResponseBuilder |
variants(List<Variant> variants)
Add a Vary header that lists the available variants.
|
protected Response.ResponseBuilder()
Response
to obtain an instance.protected static Response.ResponseBuilder newInstance()
public abstract Response build()
public abstract Response.ResponseBuilder clone()
public abstract Response.ResponseBuilder status(int status)
status
- the response statusIllegalArgumentException
- if status is less than 100 or greater
than 599.public Response.ResponseBuilder status(Response.StatusType status)
status
- the response statusIllegalArgumentException
- if status is nullpublic Response.ResponseBuilder status(Response.Status status)
status
- the response statusIllegalArgumentException
- if status is nullpublic abstract Response.ResponseBuilder entity(Object entity)
GenericEntity
if preservation of its generic type is required.entity
- the response entitypublic abstract Response.ResponseBuilder type(MediaType type)
type
- the media type of the response entity, if null any
existing value for type will be removedpublic abstract Response.ResponseBuilder type(String type)
type
- the media type of the response entity, if null any
existing value for type will be removedIllegalArgumentException
- if type cannot be parsedpublic abstract Response.ResponseBuilder variant(Variant variant)
variant
- metadata of the response entity, a null value is
equivalent to a variant with all null properties.public abstract Response.ResponseBuilder variants(List<Variant> variants)
variants
- a list of available representation variants, a null
value will remove an existing value for vary.public abstract Response.ResponseBuilder language(String language)
language
- the language of the response entity, if null any
existing value for language will be removedpublic abstract Response.ResponseBuilder language(Locale language)
language
- the language of the response entity, if null any
existing value for type will be removedpublic abstract Response.ResponseBuilder location(URI location)
location
- the location. If a relative URI is
supplied it will be converted into an absolute URI by resolving it
relative to the base URI of the application (see
UriInfo.getBaseUri()
). If null any
existing value for location will be removed.public abstract Response.ResponseBuilder contentLocation(URI location)
location
- the content location. Relative or absolute URIs
may be used for the value of content location. If null any
existing value for content location will be removed.public abstract Response.ResponseBuilder tag(EntityTag tag)
tag
- the entity tag, if null any
existing entity tag value will be removed.public abstract Response.ResponseBuilder tag(String tag)
tag(new EntityTag(value))
.tag
- the string content of a strong entity tag. The JAX-RS
runtime will quote the supplied value when creating the header. If
null any existing entity tag value will be removed.public abstract Response.ResponseBuilder lastModified(Date lastModified)
lastModified
- the last modified date, if null any existing
last modified value will be removed.public abstract Response.ResponseBuilder cacheControl(CacheControl cacheControl)
cacheControl
- the cache control directives, if null removes any
existing cache control directives.public abstract Response.ResponseBuilder expires(Date expires)
expires
- the expiration date, if null removes any existing
expires value.public abstract Response.ResponseBuilder header(String name, Object value)
name
- the name of the headervalue
- the value of the header, the header will be serialized
using a RuntimeDelegate.HeaderDelegate
if
one is available via
RuntimeDelegate.createHeaderDelegate(java.lang.Class)
for the class of value
or using its toString
method if a
header delegate is not available. If value
is null then all
current headers of the same name will be removed.public abstract Response.ResponseBuilder cookie(NewCookie... cookies)
cookies
- new cookies that will accompany the response. A null
value will remove all cookies, including those added via the
header(java.lang.String, java.lang.Object)
method.Copyright © 2018 JBoss by Red Hat. All rights reserved.