public interface GenericResponse<T> extends Closeable
This simplifies the consumption of a response with an entity body by tracking the type
information of the response entity and allowing direct access to the body via the
body() method.
To get the most value out of this class it should be used as part of a JAX-RS Resource interface definition that is shared by both a server implementation and a client auto-generated proxy. Some value can still be had by using this for client auto-generated proxies only.
Note: this is an interface, rather than an abstract class like Response, so that
implementations can implement both Response and GenericResponse.
Response| Modifier and Type | Method and Description |
|---|---|
T |
body()
Get the response entity body,
null if no entity body is present. |
void |
close()
Closes the underlying response input stream.
|
ErrorBody |
errorBody()
Get the error body,
null if the response is not an error or no entity body is present. |
Set<String> |
getAllowedMethods()
Gets the allowed HTTP methods.
|
Map<String,javax.ws.rs.core.NewCookie> |
getCookies()
Gets any new cookies on the response.
|
Date |
getDate()
Gets the resposne date,
null if not present. |
javax.ws.rs.core.EntityTag |
getEntityTag()
Gets the entity tag.
|
javax.ws.rs.core.MultivaluedMap<String,Object> |
getHeaders()
Gets a view of the response headers.
|
String |
getHeaderString(String name)
Gets a response header as a string value.
|
Locale |
getLanguage()
Gets the language of the response entity,
null if not specified. |
Date |
getLastModified()
Gets the last modified date,
null if not present. |
int |
getLength()
Gets the
Content-Length of the response if present, -1 otherwise. |
javax.ws.rs.core.Link |
getLink(String relation)
Gets the link for the relation,
null if not present. |
javax.ws.rs.core.Link.Builder |
getLinkBuilder(String relation)
Returns a link builder for the relation,
null if not present. |
Set<javax.ws.rs.core.Link> |
getLinks()
Gets the links from the response headers.
|
URI |
getLocation()
Gets the location,
null if not present. |
javax.ws.rs.core.MediaType |
getMediaType()
Gets the response entity media type, or
null of there is no response entity. |
int |
getStatus()
Get the status of the response response.
|
javax.ws.rs.core.Response.StatusType |
getStatusInfo()
Get the status of the response response.
|
javax.ws.rs.core.MultivaluedMap<String,String> |
getStringHeaders()
Gets a view of the response headers.
|
boolean |
hasLink(String relation)
Returns true if a link exists for the specified relation, false otherwise.
|
boolean |
isSuccessful()
Returns true if
getStatus() is in the range [200..300), false otherwise. |
boolean isSuccessful()
getStatus() is in the range [200..300), false otherwise.T body()
null if no entity body is present.ErrorBody errorBody()
null if the response is not an error or no entity body is present.int getStatus()
javax.ws.rs.core.Response.StatusType getStatusInfo()
void close()
close in interface AutoCloseableclose in interface Closeablejavax.ws.rs.ProcessingException - if an error occurs while closing the responseResponse.close()javax.ws.rs.core.MediaType getMediaType()
null of there is no response entity.Locale getLanguage()
null if not specified.int getLength()
Content-Length of the response if present, -1 otherwise.Map<String,javax.ws.rs.core.NewCookie> getCookies()
javax.ws.rs.core.EntityTag getEntityTag()
Date getDate()
null if not present.Date getLastModified()
null if not present.URI getLocation()
null if not present.Set<javax.ws.rs.core.Link> getLinks()
Response.getLinks()boolean hasLink(String relation)
javax.ws.rs.core.Link getLink(String relation)
null if not present.Response.getLink(String)javax.ws.rs.core.Link.Builder getLinkBuilder(String relation)
null if not present.Response.getLinkBuilder(String)javax.ws.rs.core.MultivaluedMap<String,Object> getHeaders()
Response.getHeaders(),
getStringHeaders(),
getHeaderString(java.lang.String)javax.ws.rs.core.MultivaluedMap<String,String> getStringHeaders()
Response.getStringHeaders(),
getHeaders(),
getHeaderString(java.lang.String)String getHeaderString(String name)
If the header contains multiple values, they will be joined by a ',' character,
null if the header is not present.
Response.getHeaderString(String),
getHeaders(),
getHeaderString(java.lang.String)Copyright © 2020 Cerner Innovation, Inc.. All rights reserved.