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)
Adds the pagination parameters for all parameters not already present in the given
Link . |
protected MethodParameter |
getMethodParameter()
Return the
MethodParameter to be used to potentially qualify the paging and sorting request parameters to. |
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 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.Link appendPaginationParameterTemplates(org.springframework.hateoas.Link link)
Link
.link
- 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-2014–2015 Pivotal Software, Inc.. All rights reserved.