Class Page

java.lang.Object
io.quarkus.panache.common.Page

public class Page extends Object

Utility class to represent paging information. Page instances are immutable.

Usage:

 Page page = Page.ofSize(25);
 Page secondPage = page.next();
 
Author:
Stéphane Épardaud
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final int
    The current page index (0-based).
    final int
    The current page size;
  • Constructor Summary

    Constructors
    Constructor
    Description
    Page(int size)
    Builds a page of the given size.
    Page(int index, int size)
    Builds a page of the given index and size.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a new page with the first page index (0) and the same size, or this page if it is the first page.
    index(int newIndex)
    Returns a new page at the given page index and the same size, or this page if the page index is the same.
    Returns a new page with the next page index and the same size.
    static Page
    of(int index, int size)
    Builds a page of the given index and size.
    static Page
    ofSize(int size)
    Builds a page of the given size.
    Returns a new page with the previous page index and the same size, or this page if it is the first page.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • index

      public final int index
      The current page index (0-based).
    • size

      public final int size
      The current page size;
  • Constructor Details

    • Page

      public Page(int size)
      Builds a page of the given size.
      Parameters:
      size - the page size
      Throws:
      IllegalArgumentException - if the page size is less than or equal to 0
      See Also:
    • Page

      public Page(int index, int size)
      Builds a page of the given index and size.
      Parameters:
      index - the page index (0-based)
      size - the page size
      Throws:
      IllegalArgumentException - if the page index is less than 0
      IllegalArgumentException - if the page size is less than or equal to 0
      See Also:
  • Method Details

    • of

      public static Page of(int index, int size)
      Builds a page of the given index and size.
      Parameters:
      index - the page index (0-based)
      size - the page size
      Throws:
      IllegalArgumentException - if the page index is less than 0
      IllegalArgumentException - if the page size is less than or equal to 0
    • ofSize

      public static Page ofSize(int size)
      Builds a page of the given size.
      Parameters:
      size - the page size
      Throws:
      IllegalArgumentException - if the page size is less than or equal to 0
    • next

      public Page next()
      Returns a new page with the next page index and the same size.
      Returns:
      a new page with the next page index and the same size.
      See Also:
    • previous

      public Page previous()
      Returns a new page with the previous page index and the same size, or this page if it is the first page.
      Returns:
      a new page with the next page index and the same size, or this page if it is the first page.
      See Also:
    • first

      public Page first()
      Returns a new page with the first page index (0) and the same size, or this page if it is the first page.
      Returns:
      a new page with the first page index (0) and the same size, or this page if it is the first page.
    • index

      public Page index(int newIndex)
      Returns a new page at the given page index and the same size, or this page if the page index is the same.
      Parameters:
      newIndex - the new page index
      Returns:
      a new page at the given page index and the same size, or this page if the page index is the same.