Package com.atlassian.jira.util
Class Pages
java.lang.Object
com.atlassian.jira.util.Pages
Class containing static factory methods used to create
Page
instances.- Since:
- 6.4.7
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Page<T>
page
(Iterable<T> values, long totalCount, PageRequest pageRequest) Creates a page given a list of values consisting the page, a total count of all values and a page requeststatic <T> Page<T>
toPage
(Iterable<T> allValues, PageRequest pageRequest) Given all values and a page request creates a page that conforms to the request.static <T,
R> Page<R> toPage
(Iterable<T> values, PageRequest pageRequest, Predicate<T> filter, Function<T, R> transform) Creates a page from values and aPageRequest
.
-
Constructor Details
-
Pages
public Pages()
-
-
Method Details
-
page
Creates a page given a list of values consisting the page, a total count of all values and a page request- Type Parameters:
T
- type of entities in the list- Parameters:
values
- values that appear on the pagetotalCount
- total count of all valuespageRequest
- a page request used to create this page- Returns:
- the requested page
- Throws:
IllegalArgumentException
- if arguments are inconsistent
-
toPage
Given all values and a page request creates a page that conforms to the request.- Type Parameters:
T
- type of entities in the list- Parameters:
allValues
- all not paged valuespageRequest
- page request- Returns:
- a requested page
-
toPage
public static <T,R> Page<R> toPage(Iterable<T> values, PageRequest pageRequest, Predicate<T> filter, Function<T, R> transform) Creates a page from values and aPageRequest
. This method will fill information about the the total number of values, start and size of the returned page.- Type Parameters:
T
- the type of values from which page is createdR
- the type of the page- Parameters:
values
- unfiltered and not-transformed values from which the page is createdpageRequest
- request for the pagefilter
- predicate used to filter valuestransform
- function which transforms the values from T to R- Returns:
- the page with filtered and transformed values
-