Class Pages

java.lang.Object
com.atlassian.jira.util.Pages

@PublicApi public class Pages extends Object
Class containing static factory methods used to create Page instances.
Since:
6.4.7
  • Constructor Details

    • Pages

      public Pages()
  • Method Details

    • page

      public static <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 request
      Type Parameters:
      T - type of entities in the list
      Parameters:
      values - values that appear on the page
      totalCount - total count of all values
      pageRequest - a page request used to create this page
      Returns:
      the requested page
      Throws:
      IllegalArgumentException - if arguments are inconsistent
    • toPage

      public static <T> Page<T> toPage(Iterable<T> allValues, PageRequest pageRequest)
      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 values
      pageRequest - 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 a PageRequest. 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 created
      R - the type of the page
      Parameters:
      values - unfiltered and not-transformed values from which the page is created
      pageRequest - request for the page
      filter - predicate used to filter values
      transform - function which transforms the values from T to R
      Returns:
      the page with filtered and transformed values