Spring Hateoas

org.springframework.hateoas
Class PagedResources<T>

java.lang.Object
  extended by org.springframework.hateoas.ResourceSupport
      extended by org.springframework.hateoas.Resources<T>
          extended by org.springframework.hateoas.PagedResources<T>
All Implemented Interfaces:
Iterable<T>, Identifiable<Link>

public class PagedResources<T>
extends Resources<T>

DTO to implement binding response representations of pageable collections.

Author:
Oliver Gierke

Nested Class Summary
static class PagedResources.PageMetadata
          Value object for pagination metadata.
 
Field Summary
static PagedResources<?> NO_PAGE
           
 
Constructor Summary
protected PagedResources()
          Default constructor to allow instantiation by reflection.
  PagedResources(Collection<T> content, PagedResources.PageMetadata metadata, Iterable<Link> links)
          Creates a new PagedResources from the given content PagedResources.PageMetadata and Links.
  PagedResources(Collection<T> content, PagedResources.PageMetadata metadata, Link... links)
          Creates a new PagedResources from the given content, PagedResources.PageMetadata and Links (optional).
 
Method Summary
 boolean equals(Object obj)
           
 PagedResources.PageMetadata getMetadata()
          Returns the pagination metadata.
 Link getNextLink()
          Returns the Link pointing to the next page (if set).
 Link getPreviousLink()
          Returns the Link pointing to the previous page (if set).
 int hashCode()
           
 String toString()
           
static
<T extends Resource<S>,S>
PagedResources<T>
wrap(Iterable<S> content, PagedResources.PageMetadata metadata)
          Factory method to easily create a PagedResources instance from a set of entities and pagination metadata.
 
Methods inherited from class org.springframework.hateoas.Resources
getContent, iterator, wrap
 
Methods inherited from class org.springframework.hateoas.ResourceSupport
add, add, getId, getLink, getLinks, hasLink, hasLinks, removeLinks
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_PAGE

public static PagedResources<?> NO_PAGE
Constructor Detail

PagedResources

protected PagedResources()
Default constructor to allow instantiation by reflection.


PagedResources

public PagedResources(Collection<T> content,
                      PagedResources.PageMetadata metadata,
                      Link... links)
Creates a new PagedResources from the given content, PagedResources.PageMetadata and Links (optional).

Parameters:
content - must not be null.
metadata -
links -

PagedResources

public PagedResources(Collection<T> content,
                      PagedResources.PageMetadata metadata,
                      Iterable<Link> links)
Creates a new PagedResources from the given content PagedResources.PageMetadata and Links.

Parameters:
content - must not be null.
metadata -
links -
Method Detail

getMetadata

public PagedResources.PageMetadata getMetadata()
Returns the pagination metadata.

Returns:
the metadata

wrap

public static <T extends Resource<S>,S> PagedResources<T> wrap(Iterable<S> content,
                                                               PagedResources.PageMetadata metadata)
Factory method to easily create a PagedResources instance from a set of entities and pagination metadata.

Parameters:
content - must not be null.
metadata -
Returns:

getNextLink

public Link getNextLink()
Returns the Link pointing to the next page (if set).

Returns:
See Also:
#addPaginationLinks(Link)

getPreviousLink

public Link getPreviousLink()
Returns the Link pointing to the previous page (if set).

Returns:
See Also:
#addPaginationLinks(Link)

toString

public String toString()
Overrides:
toString in class Resources<T>

equals

public boolean equals(Object obj)
Overrides:
equals in class Resources<T>

hashCode

public int hashCode()
Overrides:
hashCode in class Resources<T>

Spring Hateoas

Copyright © 2012-2014–2014 Pivotal, Inc.. All rights reserved.