public class PagedResourcesAssembler<T> extends Object implements org.springframework.hateoas.ResourceAssembler<Page<T>,org.springframework.hateoas.PagedResources<org.springframework.hateoas.Resource<T>>>
| Constructor and Description |
|---|
PagedResourcesAssembler(HateoasPageableHandlerMethodArgumentResolver resolver,
UriComponents baseUri)
Creates a new
PagedResourcesAssembler using the given PageableHandlerMethodArgumentResolver and
base URI. |
| Modifier and Type | Method and Description |
|---|---|
org.springframework.hateoas.Link |
appendPaginationParameterTemplates(org.springframework.hateoas.Link link)
Deprecated.
this method will be removed in 1.11 as no Spring Data module actually calls it. Other clients calling
it should stop doing so as
Links used for pagination shouldn't be templated in the first place. |
protected <R extends org.springframework.hateoas.ResourceSupport,S> |
createPagedResource(List<R> resources,
org.springframework.hateoas.PagedResources.PageMetadata metadata,
Page<S> page)
Creates the
PagedResources to be equipped with pagination links downstream. |
protected MethodParameter |
getMethodParameter()
Return the
MethodParameter to be used to potentially qualify the paging and sorting request parameters to. |
void |
setForceFirstAndLastRels(boolean forceFirstAndLastRels)
Configures whether to always add
first and last links to the PagedResources created. |
org.springframework.hateoas.PagedResources<?> |
toEmptyResource(Page<?> page,
Class<?> type,
org.springframework.hateoas.Link link)
Creates a
PagedResources with an empt collection EmbeddedWrapper for the given domain type. |
org.springframework.hateoas.PagedResources<org.springframework.hateoas.Resource<T>> |
toResource(Page<T> entity) |
org.springframework.hateoas.PagedResources<org.springframework.hateoas.Resource<T>> |
toResource(Page<T> page,
org.springframework.hateoas.Link selfLink)
Creates a new
PagedResources by converting the given Page into a PagedResources.PageMetadata instance and
wrapping the contained elements into Resource instances. |
<R extends org.springframework.hateoas.ResourceSupport> |
toResource(Page<T> page,
org.springframework.hateoas.ResourceAssembler<T,R> assembler)
|
<R extends org.springframework.hateoas.ResourceSupport> |
toResource(Page<T> page,
org.springframework.hateoas.ResourceAssembler<T,R> assembler,
org.springframework.hateoas.Link link)
|
public PagedResourcesAssembler(HateoasPageableHandlerMethodArgumentResolver resolver, UriComponents baseUri)
PagedResourcesAssembler using the given PageableHandlerMethodArgumentResolver and
base URI. If the former is null, a default one will be created. If the latter is null, calls
to toResource(Page) will use the current request's URI to build the relevant previous and next links.resolver - baseUri - public void setForceFirstAndLastRels(boolean forceFirstAndLastRels)
first and last links to the PagedResources created.
Defaults to false which means that first and last links only appear in conjunction with
prev and next links.forceFirstAndLastRels - whether to always add first and last links to the
PagedResources created.public org.springframework.hateoas.PagedResources<org.springframework.hateoas.Resource<T>> toResource(Page<T> entity)
public org.springframework.hateoas.PagedResources<org.springframework.hateoas.Resource<T>> toResource(Page<T> page, org.springframework.hateoas.Link selfLink)
PagedResources by converting the given Page into a PagedResources.PageMetadata instance and
wrapping the contained elements into Resource instances. Will add pagination links based on the given the
self link.page - must not be null.selfLink - must not be null.public <R extends org.springframework.hateoas.ResourceSupport> org.springframework.hateoas.PagedResources<R> toResource(Page<T> page, org.springframework.hateoas.ResourceAssembler<T,R> assembler)
PagedResources by converting the given Page into a PagedResources.PageMetadata instance and
using the given ResourceAssembler to turn elements of the Page into resources.page - must not be null.assembler - must not be null.public <R extends org.springframework.hateoas.ResourceSupport> org.springframework.hateoas.PagedResources<R> toResource(Page<T> page, org.springframework.hateoas.ResourceAssembler<T,R> assembler, org.springframework.hateoas.Link link)
PagedResources by converting the given Page into a PagedResources.PageMetadata instance and
using the given ResourceAssembler to turn elements of the Page into resources. Will add pagination
links based on the given the self link.page - must not be null.assembler - must not be null.link - must not be null.public org.springframework.hateoas.PagedResources<?> toEmptyResource(Page<?> page, Class<?> type, org.springframework.hateoas.Link link)
PagedResources with an empt collection EmbeddedWrapper for the given domain type.page - must not be null, content must be empty.type - must not be null.link - can be null.@Deprecated public org.springframework.hateoas.Link appendPaginationParameterTemplates(org.springframework.hateoas.Link link)
Links used for pagination shouldn't be templated in the first place.Link.link - must not be null.protected <R extends org.springframework.hateoas.ResourceSupport,S> org.springframework.hateoas.PagedResources<R> createPagedResource(List<R> resources, org.springframework.hateoas.PagedResources.PageMetadata metadata, Page<S> page)
PagedResources to be equipped with pagination links downstream.resources - the original page's elements mapped into ResourceSupport instances.metadata - the calculated PagedResources.PageMetadata, must not be null.page - the original page handed to the assembler, must not be null.protected MethodParameter getMethodParameter()
MethodParameter to be used to potentially qualify the paging and sorting request parameters to.
Default implementations returns null, which means the parameters will not be qualified.Copyright © 2011-2016–2017 Pivotal Software, Inc.. All rights reserved.