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 aPageholding given content. -
Method Summary
Modifier and Type Method Description java.util.List<T>getContent()Return the content for thisPage.intgetLastPageNumber()Calculate and return the last page number.PageRequestgetPageRequest()Return thePageRequestfor thisPage.longgetTotal()Return the current total size of data available.java.util.Iterator<T>iterator()Return an iterator for the page's content.PageRequestnextPageRequest()Return the nextPageRequest.PageRequestpreviousPageRequest()Return the previousPageRequest.
-
Constructor Details
-
Page
Create aPageholding given content.- Parameters:
content- the list of contentpageRequest- thePageRequestinvolved in creating thisPagetotal- 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 currentPageRequestis the last page, thisPageRequestis returned. -
previousPageRequest
Return the previousPageRequest. If the currentPageRequestis the first page, thisPageRequestis 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 lastPageRequestand 1 is subtracted because counting starts at 0. -
getPageRequest
Return thePageRequestfor thisPage. -
getContent
Return the content for thisPage. -
iterator
Return an iterator for the page's content.- Specified by:
iteratorin interfacejava.lang.Iterable<T>
-