T - the type of the raw datapublic abstract class AbstractResponse<T> extends Object implements ResponseStream
| Modifier and Type | Field and Description |
|---|---|
protected Stream<T> |
entries |
protected ObjectMappersSuite |
objectMappers |
protected Pagination<?> |
pages |
protected javax.ws.rs.core.UriInfo |
uriInfo |
| Constructor and Description |
|---|
AbstractResponse(Stream<T> entries,
Pagination<?> pages,
javax.ws.rs.core.UriInfo uriInfo,
ObjectMappersSuite objectMappers)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
addLink(PaginationLink link,
int pageNumber,
int perPage,
javax.ws.rs.core.UriBuilder uriBuilder,
MappingResponseProcessor responseProcessor,
Map<String,URI> bodyLinks)
Adds the specified link to the headers and to the map of links that will be added to the body of the response.
|
static void |
addLink(PaginationLink link,
Pagination<?> pages,
javax.ws.rs.core.UriBuilder uriBuilder,
Map<String,URI> bodyLinks)
Adds the specified link to the headers and body of the response.
|
static void |
addLink(PaginationLink link,
Pagination<?> pages,
javax.ws.rs.core.UriBuilder uriBuilder,
MappingResponseProcessor responseProcessor,
Map<String,URI> bodyLinks)
Adds the specified link to the headers and body of the response.
|
static Map<String,Object> |
addLinks(Pagination<?> pages,
javax.ws.rs.core.UriBuilder uriBuilder)
Returns all required pagination links.
|
static void |
addLinks(Pagination<?> pages,
javax.ws.rs.core.UriBuilder uriBuilder,
MappingResponseProcessor responseProcessor)
Adds all the required pagination links to the headers and body of the response.
|
javax.ws.rs.core.StreamingOutput |
getResponseStream()
Get a resource method that can be used to stream this response as an entity.
|
abstract void |
write(OutputStream outputStream)
Write the response to the output stream.
|
void |
writeMetaObject(com.fasterxml.jackson.core.JsonGenerator generator,
javax.ws.rs.core.UriBuilder uriBuilder)
Builds the meta data entry of the page if such data is present.
|
protected final javax.ws.rs.core.UriInfo uriInfo
protected final Pagination<?> pages
protected final ObjectMappersSuite objectMappers
public AbstractResponse(Stream<T> entries, Pagination<?> pages, javax.ws.rs.core.UriInfo uriInfo, ObjectMappersSuite objectMappers)
entries - The data entries to generate the response foruriInfo - UriInfo to generate the URL for the page linkspages - The paginated set of results containing the pages being linked to.objectMappers - Suite of Object Mappers to use when serializing the responsepublic javax.ws.rs.core.StreamingOutput getResponseStream()
getResponseStream in interface ResponseStreampublic abstract void write(OutputStream outputStream) throws IOException
outputStream - Output stream to write toIOException - if there's a problem writing to the streampublic static Map<String,Object> addLinks(Pagination<?> pages, javax.ws.rs.core.UriBuilder uriBuilder)
pages - The paginated set of results containing the pages being linked to.uriBuilder - The builder for creating the pagination links.public static void addLink(PaginationLink link, Pagination<?> pages, javax.ws.rs.core.UriBuilder uriBuilder, Map<String,URI> bodyLinks)
link - The type of the link being addedpages - The paginated set of results containing the pages being linked to.uriBuilder - The builder for creating the pagination links.bodyLinks - The map of links that will be added to the body of the responsepublic static void addLinks(Pagination<?> pages, javax.ws.rs.core.UriBuilder uriBuilder, MappingResponseProcessor responseProcessor)
pages - The paginated set of results containing the pages being linked to.uriBuilder - The uri builder to build the linksresponseProcessor - The response processor whose links are being builtpublic static void addLink(PaginationLink link, Pagination<?> pages, javax.ws.rs.core.UriBuilder uriBuilder, MappingResponseProcessor responseProcessor, Map<String,URI> bodyLinks)
link - The type of the link being addedpages - The paginated set of results containing the pages being linked to.uriBuilder - The uri builder to build the linksresponseProcessor - The response processor whose links are being builtbodyLinks - The map of links that will be added to the body of the responsepublic static void addLink(PaginationLink link, int pageNumber, int perPage, javax.ws.rs.core.UriBuilder uriBuilder, MappingResponseProcessor responseProcessor, Map<String,URI> bodyLinks)
link - The type of the link being addedpageNumber - The page being linked toperPage - The number of result rows in the page being linked touriBuilder - The uri builder to build the linksresponseProcessor - The response processor whose links are being builtbodyLinks - The map of links that will be added to the body of the responsepublic void writeMetaObject(com.fasterxml.jackson.core.JsonGenerator generator,
javax.ws.rs.core.UriBuilder uriBuilder)
throws IOException
generator - The JsonGenerator used to build the JSON response.uriBuilder - The builder for creating the pagination links.IOException - if the generator throws an IOException.Copyright © 2016–2018 Yahoo! Inc.. All rights reserved.