Class 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) or usingOneAsFirstPage().

    You can also indicate whether a sort has been applied to the data by setting the KiwiSort via the setter method or via addKiwiSort(KiwiSort).

    • Constructor Detail

      • KiwiPage

        public KiwiPage()
    • 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 the addKiwiSort(KiwiSort) and usingOneAsFirstPage() 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 limit
        total - the total number of elements in the overall result list
        contentList - the content on this page
        Returns:
        a new instance
        Throws:
        IllegalStateException - if any of the numeric arguments are negative or the limit is zero
        IllegalArgumentException - 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()
        Sets pagingStartsWith to 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()
        Sets pagingStartsWith to 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