Class PaginationResult<O>
java.lang.Object
org.nuiton.util.pagination.PaginationResult<O>
- All Implemented Interfaces:
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:
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPaginationResult(List<O> elements, long count, PaginationParameter currentPage) -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> PaginationResult<T> empty(PaginationParameter requestedPage) Creates an instance for an empty result.static <T> PaginationResult<T> fromFullList(List<T> fullList, PaginationParameter requestedPage) Creates an instance using the full list of elements ({code}fullList{/code}) and the {code}requestedPage{/code}PaginationParameter.longgetCount()intbooleanbooleanstatic <T> PaginationResult<T> of(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> Creates an instance of PaginationResult transforming the current one using the given function for each element<T> PaginationResult<T> transformAll(Function<List<O>, List<T>> function) Creates an instance of PaginationResult transforming the current one using the given function for all elements
-
Field Details
-
elements
-
count
protected long count -
currentPage
-
-
Constructor Details
-
PaginationResult
-
-
Method Details
-
of
public static <T> PaginationResult<T> of(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(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.
-
empty
Creates an instance for an empty result.- Type Parameters:
T- any object type- Parameters:
requestedPage- the PaginationParameter to use to build this paged result- Returns:
- the built empty instance.
-
getElements
-
getCount
public long getCount() -
getCurrentPage
-
getNextPage
-
getPreviousPage
-
getFirstPage
-
getLastPage
-
getPageCount
public int getPageCount() -
hasNextPage
public boolean hasNextPage() -
hasPreviousPage
public boolean hasPreviousPage() -
transform
Creates an instance of PaginationResult transforming the current one using the given function for each element -
transformAll
Creates an instance of PaginationResult transforming the current one using the given function for all elements
-