Interface Pageable

All Superinterfaces:
Sort
All Known Subinterfaces:
CursoredPageable

@Introspected public interface Pageable extends Sort
Models pageable data. The from(int, int) method can be used to construct a new instance to pass to Micronaut Data methods.
Since:
1.0.0
Author:
boros, graemerocher
  • Field Details

    • UNPAGED

      static final Pageable UNPAGED
      Constant for no pagination.
  • Method Details

    • getNumber

      int getNumber()
      Returns:
      The page page.
    • getSize

      int getSize()
      Maximum size of the page to be returned. A value of -1 indicates no maximum.
      Returns:
      size of the requested page of items
    • getMode

      default Pageable.Mode getMode()
      The pagination mode that is either offset pagination, currentCursor forward or currentCursor backward pagination.
      Returns:
      The pagination mode
      Since:
      4.8.0
    • cursor

      default Optional<Pageable.Cursor> cursor()
      Get the currentCursor in case cursored pagination is used.
      Returns:
      The currentCursor
      Since:
      4.8.0
    • requestTotal

      default boolean requestTotal()
      Whether the returned page should contain information about total items that can be produced by this query. If the value is false, Page.getTotalSize() and Page.getTotalPages() methods will fail. By default, pageable will have this value set to true.
      Returns:
      Whether total size information is required.
      Since:
      4.8.0
    • getOffset

      default long getOffset()
      Offset in the requested collection. Defaults to zero.
      Returns:
      offset in the requested collection
    • getSort

      @NonNull default @NonNull Sort getSort()
      Returns:
      The sort definition to use.
    • next

      @NonNull default @NonNull Pageable next()
      Returns:
      The next pageable.
    • previous

      @NonNull default @NonNull Pageable previous()
      Returns:
      The previous pageable
    • isUnpaged

      default boolean isUnpaged()
      Returns:
      Whether it is unpaged
    • order

      @NonNull default @NonNull Pageable order(@NonNull @NonNull String propertyName)
      Description copied from interface: Sort
      Orders by the specified property name (defaults to ascending).
      Specified by:
      order in interface Sort
      Parameters:
      propertyName - The property name to order by
      Returns:
      A new sort with the order applied
    • isSorted

      default boolean isSorted()
      Specified by:
      isSorted in interface Sort
      Returns:
      Is sorting applied
    • order

      @NonNull default @NonNull Pageable order(@NonNull @NonNull Sort.Order order)
      Description copied from interface: Sort
      Adds an order object.
      Specified by:
      order in interface Sort
      Parameters:
      order - The order object
      Returns:
      A new sort with the order applied
    • order

      @NonNull default @NonNull Pageable order(@NonNull @NonNull String propertyName, @NonNull Sort.Order.Direction direction)
      Description copied from interface: Sort
      Orders by the specified property name and direction.
      Specified by:
      order in interface Sort
      Parameters:
      propertyName - The property name to order by
      direction - Either "asc" for ascending or "desc" for descending
      Returns:
      A new sort with the order applied
    • orders

      @NonNull default @NonNull Pageable orders(@NonNull @NonNull List<Sort.Order> orders)
      Description copied from interface: Sort
      Adds an orders.
      Specified by:
      orders in interface Sort
      Parameters:
      orders - The orders
      Returns:
      A new sort with the order applied
    • withoutSort

      @NonNull default @NonNull Pageable withoutSort()
      Removes ordering.
      Returns:
      A pageable without ordering
      Since:
      4.10
    • withoutPaging

      @NonNull default @NonNull Pageable withoutPaging()
      Removes paging.
      Returns:
      A pageable without paging
      Since:
      4.10
    • withSort

      default Pageable withSort(@NonNull @NonNull Sort sort)
      Creates a new Pageable with a custom sort.
      Parameters:
      sort - a new sort
      Returns:
      A pageable instance with a new sort
      Since:
      4.10
    • getOrderBy

      @NonNull default @NonNull List<Sort.Order> getOrderBy()
      Specified by:
      getOrderBy in interface Sort
      Returns:
      The order definitions for this sort.
    • withTotal

      default Pageable withTotal()
      Specify that the Page response should have information about total size.
      Returns:
      A pageable instance that will request the total size.
      Since:
      4.8.0
      See Also:
    • withoutTotal

      default Pageable withoutTotal()
      Specify that the Page response should not have information about total size.
      Returns:
      A pageable instance that won't request the total size.
      Since:
      4.8.0
      See Also:
    • from

      @NonNull static @NonNull Pageable from(int page)
      Creates a new Pageable at the given offset with a default size of 10.
      Parameters:
      page - The page
      Returns:
      The pageable
    • from

      @NonNull static @NonNull Pageable from(int page, int size)
      Creates a new Pageable at the given offset.
      Parameters:
      page - The page
      size - the size
      Returns:
      The pageable
    • from

      @NonNull static @NonNull Pageable from(int page, int size, @Nullable @Nullable Sort sort)
      Creates a new Pageable with the given offset.
      Parameters:
      page - The page
      size - the size
      sort - the sort
      Returns:
      The pageable
    • from

      @Internal @NonNull static @NonNull Pageable from(int page, int size, @Nullable @Nullable Pageable.Mode mode, @Nullable @Nullable Pageable.Cursor cursor, @Nullable @Nullable Sort sort, boolean requestTotal)
      Creates a new Pageable with the given parameters. The method is used for deserialization and most likely should not be used as an API.
      Parameters:
      page - The page
      size - The size
      mode - The pagination mode
      cursor - The current cursor
      sort - The sort
      requestTotal - Whether to query total count
      Returns:
      The pageable
    • from

      @NonNull static @NonNull Pageable from(Sort sort)
      Creates a new Pageable at the given offset.
      Parameters:
      sort - the sort
      Returns:
      The pageable
    • unpaged

      @NonNull static @NonNull Pageable unpaged()
      Returns:
      A new instance without paging data.
    • afterCursor

      @NonNull static @NonNull CursoredPageable afterCursor(@NonNull @NonNull Pageable.Cursor cursor, int page, int size, @Nullable @Nullable Sort sort)
      Create a new Pageable for forward pagination given the currentCursor after which to query.
      Parameters:
      cursor - The currentCursor
      page - The page page
      size - The page size
      sort - The sorting
      Returns:
      The pageable
      Since:
      4.8.0
    • beforeCursor

      @NonNull static @NonNull CursoredPageable beforeCursor(@NonNull @NonNull Pageable.Cursor cursor, int page, int size, @Nullable @Nullable Sort sort)
      Create a new Pageable for backward pagination given the currentCursor after which to query.
      Parameters:
      cursor - The currentCursor
      page - The page page
      size - The page size
      sort - The sorting
      Returns:
      The pageable
      Since:
      4.8.0