Package NTNU.IDATT1002.repository
Class Page<T>
java.lang.Object
NTNU.IDATT1002.repository.Page<T>
- Type Parameters:
T
- The type of data, preferably an entity.
- All Implemented Interfaces:
java.lang.Iterable<T>
public class Page<T>
extends java.lang.Object
implements java.lang.Iterable<T>
Provides operations for navigating between pages. A page contains a list of data which type and size
are determined by the previous
PageRequest
before this page was created.
The page does not care what type of data it is holding.-
Constructor Summary
Constructors Constructor Description Page(java.util.List<T> content, PageRequest pageRequest, long total)
Create aPage
holding given content. -
Method Summary
Modifier and Type Method Description java.util.List<T>
getContent()
Return the content for thisPage
.int
getLastPageNumber()
Calculate and return the last page number.PageRequest
getPageRequest()
Return thePageRequest
for thisPage
.long
getTotal()
Return the current total size of data available.java.util.Iterator<T>
iterator()
Return an iterator for the page's content.PageRequest
nextPageRequest()
Return the nextPageRequest
.PageRequest
previousPageRequest()
Return the previousPageRequest
.
-
Constructor Details
-
Page
Create aPage
holding given content.- Parameters:
content
- the list of contentpageRequest
- thePageRequest
involved in creating thisPage
total
- the current total size of data available. The last page number is calculated with this number.- Throws:
java.lang.IllegalArgumentException
- if total is negative
-
-
Method Details
-
nextPageRequest
Return the nextPageRequest
. If the currentPageRequest
is the last page, thisPageRequest
is returned. -
previousPageRequest
Return the previousPageRequest
. If the currentPageRequest
is the first page, thisPageRequest
is returned. -
getTotal
public long getTotal()Return the current total size of data available. -
getLastPageNumber
public int getLastPageNumber()Calculate and return the last page number. This number is rounded up to include the results left over in the lastPageRequest
and 1 is subtracted because counting starts at 0. -
getPageRequest
Return thePageRequest
for thisPage
. -
getContent
Return the content for thisPage
. -
iterator
Return an iterator for the page's content.- Specified by:
iterator
in interfacejava.lang.Iterable<T>
-