Spring Data Core

org.springframework.data.web
Class PagedResourcesAssembler<T>

java.lang.Object
  extended by org.springframework.data.web.PagedResourcesAssembler<T>
All Implemented Interfaces:
org.springframework.hateoas.ResourceAssembler<Page<T>,org.springframework.hateoas.PagedResources<org.springframework.hateoas.Resource<T>>>

public class PagedResourcesAssembler<T>
extends Object
implements org.springframework.hateoas.ResourceAssembler<Page<T>,org.springframework.hateoas.PagedResources<org.springframework.hateoas.Resource<T>>>

ResourceAssembler to easily convert Page instances into PagedResources.

Since:
1.6
Author:
Oliver Gierke, Nick Williams

Constructor Summary
PagedResourcesAssembler(HateoasPageableHandlerMethodArgumentResolver resolver, UriComponents baseUri)
          Creates a new PagedResourcesAssembler using the given PageableHandlerMethodArgumentResolver and base URI.
 
Method Summary
 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>
org.springframework.hateoas.PagedResources<R>
toResource(Page<T> page, org.springframework.hateoas.ResourceAssembler<T,R> assembler)
          Creates a new PagedResources by converting the given Page into a PagedResources.PageMetadata instance and using the given ResourceAssembler to turn elements of the Page into resources.
<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)
          Creates a new PagedResources by converting the given Page into a PagedResources.PageMetadata instance and using the given ResourceAssembler to turn elements of the Page into resources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PagedResourcesAssembler

public PagedResourcesAssembler(HateoasPageableHandlerMethodArgumentResolver resolver,
                               UriComponents baseUri)
Creates a new 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.

Parameters:
resolver -
baseUri -
Method Detail

toResource

public org.springframework.hateoas.PagedResources<org.springframework.hateoas.Resource<T>> toResource(Page<T> entity)
Specified by:
toResource in interface org.springframework.hateoas.ResourceAssembler<Page<T>,org.springframework.hateoas.PagedResources<org.springframework.hateoas.Resource<T>>>

toResource

public 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. Will add pagination links based on the given the self link.

Parameters:
page - must not be null.
selfLink - must not be null.
Returns:

toResource

public <R extends org.springframework.hateoas.ResourceSupport> org.springframework.hateoas.PagedResources<R> toResource(Page<T> page,
                                                                                                                        org.springframework.hateoas.ResourceAssembler<T,R> assembler)
Creates a new PagedResources by converting the given Page into a PagedResources.PageMetadata instance and using the given ResourceAssembler to turn elements of the Page into resources.

Parameters:
page - must not be null.
assembler - must not be null.
Returns:

toResource

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)
Creates a new 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.

Parameters:
page - must not be null.
assembler - must not be null.
link - must not be null.
Returns:

Spring Data Core

Copyright © 2011-2013-2013 Pivotal. All Rights Reserved.