Spring Data Core

org.springframework.data.domain
Class PageImpl<T>

java.lang.Object
  extended by org.springframework.data.domain.PageImpl<T>
Type Parameters:
T - the type of which the page consists.
All Implemented Interfaces:
Serializable, Iterable<T>, Page<T>

public class PageImpl<T>
extends Object
implements Page<T>, Serializable

Basic Page implementation.

Author:
Oliver Gierke
See Also:
Serialized Form

Constructor Summary
PageImpl(List<T> content)
          Creates a new PageImpl with the given content.
PageImpl(List<T> content, Pageable pageable, long total)
          Constructor of PageImpl.
 
Method Summary
 boolean equals(Object obj)
           
 List<T> getContent()
          Returns the page content as List.
 int getNumber()
          Returns the number of the current page.
 int getNumberOfElements()
          Returns the number of elements currently on this page.
 int getSize()
          Returns the size of the page.
 Sort getSort()
          Returns the sorting parameters for the page.
 long getTotalElements()
          Returns the total amount of elements.
 int getTotalPages()
          Returns the number of total pages.
 boolean hasContent()
          Returns whether the Page has content at all.
 int hashCode()
           
 boolean hasNextPage()
          Returns if there is a next page.
 boolean hasPreviousPage()
          Returns if there is a previous page.
 boolean isFirstPage()
          Returns whether the current page is the first one.
 boolean isLastPage()
          Returns whether the current page is the last one.
 Iterator<T> iterator()
           
 Pageable nextPageable()
          Returns the Pageable to request the next Page.
 Pageable previousPageable()
          Returns the Pageable to request the previous page.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PageImpl

public PageImpl(List<T> content,
                Pageable pageable,
                long total)
Constructor of PageImpl.

Parameters:
content - the content of this page, must not be null.
pageable - the paging information, can be null.
total - the total amount of items available

PageImpl

public PageImpl(List<T> content)
Creates a new PageImpl with the given content. This will result in the created Page being identical to the entire List.

Parameters:
content - must not be null.
Method Detail

getNumber

public int getNumber()
Description copied from interface: Page
Returns the number of the current page. Is always non-negative and less that Page#getTotalPages().

Specified by:
getNumber in interface Page<T>
Returns:
the number of the current page

getSize

public int getSize()
Description copied from interface: Page
Returns the size of the page.

Specified by:
getSize in interface Page<T>
Returns:
the size of the page

getTotalPages

public int getTotalPages()
Description copied from interface: Page
Returns the number of total pages.

Specified by:
getTotalPages in interface Page<T>
Returns:
the number of toral pages

getNumberOfElements

public int getNumberOfElements()
Description copied from interface: Page
Returns the number of elements currently on this page.

Specified by:
getNumberOfElements in interface Page<T>
Returns:
the number of elements currently on this page

getTotalElements

public long getTotalElements()
Description copied from interface: Page
Returns the total amount of elements.

Specified by:
getTotalElements in interface Page<T>
Returns:
the total amount of elements

hasPreviousPage

public boolean hasPreviousPage()
Description copied from interface: Page
Returns if there is a previous page.

Specified by:
hasPreviousPage in interface Page<T>
Returns:
if there is a previous page

isFirstPage

public boolean isFirstPage()
Description copied from interface: Page
Returns whether the current page is the first one.

Specified by:
isFirstPage in interface Page<T>
Returns:

hasNextPage

public boolean hasNextPage()
Description copied from interface: Page
Returns if there is a next page.

Specified by:
hasNextPage in interface Page<T>
Returns:
if there is a next page

isLastPage

public boolean isLastPage()
Description copied from interface: Page
Returns whether the current page is the last one.

Specified by:
isLastPage in interface Page<T>
Returns:

nextPageable

public Pageable nextPageable()
Description copied from interface: Page
Returns the Pageable to request the next Page. Can be null in case the current Page is already the last one. Clients should check Page.hasNextPage() before calling this method to make sure they receive a non-null value.

Specified by:
nextPageable in interface Page<T>
Returns:

previousPageable

public Pageable previousPageable()
Description copied from interface: Page
Returns the Pageable to request the previous page. Can be null in case the current Page is already the first one. Clients should check Page.hasPreviousPage() before calling this method make sure receive a non-null value.

Specified by:
previousPageable in interface Page<T>
Returns:

iterator

public Iterator<T> iterator()
Specified by:
iterator in interface Iterable<T>
Specified by:
iterator in interface Page<T>

getContent

public List<T> getContent()
Description copied from interface: Page
Returns the page content as List.

Specified by:
getContent in interface Page<T>
Returns:

hasContent

public boolean hasContent()
Description copied from interface: Page
Returns whether the Page has content at all.

Specified by:
hasContent in interface Page<T>
Returns:

getSort

public Sort getSort()
Description copied from interface: Page
Returns the sorting parameters for the page.

Specified by:
getSort in interface Page<T>
Returns:

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

Spring Data Core

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