Package org.kiwiproject.spring.data
Class KiwiPage<T>
- java.lang.Object
-
- org.kiwiproject.spring.data.KiwiPage<T>
-
- Type Parameters:
T- the type of content this page contains
public class KiwiPage<T> extends Object
Represents one page of an overall list of results.By default, pagination assumes a start page index of 0 (i.e. the page offset). You can change this by calling
setPagingStartsWith(int)orusingOneAsFirstPage().You can also indicate whether a sort has been applied to the data by setting the
KiwiSortvia the setter method or viaaddKiwiSort(KiwiSort).
-
-
Constructor Summary
Constructors Constructor Description KiwiPage()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description KiwiPage<T>addKiwiSort(KiwiSort sort)Adds the given sort, returning this instance for method chaining.booleanisFirst()Determines if this is the first page when paginating a result list.booleanisLast()Determines if this is the last page when paginating a result list.booleanisSorted()Does this page have a sort applied?static <T> KiwiPage<T>of(long pageNum, long limit, long total, List<T> contentList)Create a new instance.KiwiPage<T>usingOneAsFirstPage()SetspagingStartsWithto zero, so that pagination assumes one-based page numbering.KiwiPage<T>usingZeroAsFirstPage()SetspagingStartsWithto zero, so that pagination assumes zero-based page numbering.
-
-
-
Method Detail
-
of
public static <T> KiwiPage<T> of(long pageNum, long limit, long total, List<T> contentList)
Create a new instance.If you need to add a sort or change
pagingStartsWith, you can chain theaddKiwiSort(KiwiSort)andusingOneAsFirstPage()in a fluent style.- Type Parameters:
T- the type of elements on this page- Parameters:
pageNum- the number of this page, can be 0 or 1-based (0 is the default)limit- the page size limittotal- the total number of elements in the overall result listcontentList- the content on this page- Returns:
- a new instance
- Throws:
IllegalStateException- if any of the numeric arguments are negative or the limit is zeroIllegalArgumentException- if contentList is null
-
addKiwiSort
public KiwiPage<T> addKiwiSort(KiwiSort sort)
Adds the given sort, returning this instance for method chaining.- Parameters:
sort- the sort to add- Returns:
- this instance
-
usingZeroAsFirstPage
public KiwiPage<T> usingZeroAsFirstPage()
SetspagingStartsWithto zero, so that pagination assumes zero-based page numbering.This can also be done via the setter method, but it does not permit method chaining.
- Returns:
- this instance
-
usingOneAsFirstPage
public KiwiPage<T> usingOneAsFirstPage()
SetspagingStartsWithto zero, so that pagination assumes one-based page numbering.This can also be done via the setter method, but it does not permit method chaining.
- Returns:
- this instance
-
isFirst
public boolean isFirst()
Determines if this is the first page when paginating a result list.- Returns:
- true if this is the first page
-
isLast
public boolean isLast()
Determines if this is the last page when paginating a result list.- Returns:
- true if this is the last page
-
isSorted
public boolean isSorted()
Does this page have a sort applied?- Returns:
- true if this page has a sort applied
-
-