Package org.nuiton.util.pagination
Class PaginationResult<O>
java.lang.Object
org.nuiton.util.pagination.PaginationResult<O>
- All Implemented Interfaces:
java.io.Serializable
public class PaginationResult<O>
extends java.lang.Object
implements java.io.Serializable
Represents the result of a pagination request. It contains the result elements together with the
PaginationParameter used to compute it. The class also contains methods to
navigate through the other pages.- Since:
- 3.0
- Author:
- Arnaud Thimel (Code Lutin)
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description protected longcountprotected PaginationParametercurrentPageprotected java.util.List<O>elements -
Constructor Summary
Constructors Modifier Constructor Description protectedPaginationResult(java.util.List<O> elements, long count, PaginationParameter currentPage) -
Method Summary
Modifier and Type Method Description static <T> PaginationResult<T>fromFullList(java.util.List<T> fullList, PaginationParameter requestedPage)Creates an instance using the full list of elements ({code}fullList{/code}) and the {code}requestedPage{/code}PaginationParameter.longgetCount()PaginationParametergetCurrentPage()java.util.List<O>getElements()PaginationParametergetFirstPage()PaginationParametergetLastPage()PaginationParametergetNextPage()intgetPageCount()PaginationParametergetPreviousPage()booleanhasNextPage()booleanhasPreviousPage()static <T> PaginationResult<T>of(java.util.List<T> elements, long count, PaginationParameter currentPage)Creates an instance using the already computed list of {code}elements{/code} and {code}count{/count}, together with the {code}currentPage{/code}PaginationParameterused to build it.<T> PaginationResult<T>transform(java.util.function.Function<? super O,? extends T> function)Creates an instance of PaginationResult transforming the current one using the given function
-
Field Details
-
elements
-
count
protected long count -
currentPage
-
-
Constructor Details
-
PaginationResult
protected PaginationResult(java.util.List<O> elements, long count, PaginationParameter currentPage)
-
-
Method Details
-
of
public static <T> PaginationResult<T> of(java.util.List<T> elements, long count, PaginationParameter currentPage)Creates an instance using the already computed list of {code}elements{/code} and {code}count{/count}, together with the {code}currentPage{/code}PaginationParameterused to build it.- Type Parameters:
T- any object type- Parameters:
elements- the list of elementscount- the total number of elements (through all pages)currentPage- the PaginationParameter used to build this paged result- Returns:
- the built instance of PaginationResult
-
fromFullList
public static <T> PaginationResult<T> fromFullList(java.util.List<T> fullList, PaginationParameter requestedPage)Creates an instance using the full list of elements ({code}fullList{/code}) and the {code}requestedPage{/code}PaginationParameter. The built instance of PaginationResult will contain a sub list of the given {code}fullList{/code} parameter.- Type Parameters:
T- any object type- Parameters:
fullList- the full list of elementsrequestedPage- the PaginationParameter to use to build this paged result- Returns:
- the built instance of PaginationResult.
-
getElements
-
getCount
public long getCount() -
getCurrentPage
-
getNextPage
-
getPreviousPage
-
getFirstPage
-
getLastPage
-
getPageCount
public int getPageCount() -
hasNextPage
public boolean hasNextPage() -
hasPreviousPage
public boolean hasPreviousPage() -
transform
public <T> PaginationResult<T> transform(java.util.function.Function<? super O,? extends T> function)Creates an instance of PaginationResult transforming the current one using the given function
-