Interface CursoredPage<T>

Type Parameters:
T - The generic type
All Superinterfaces:
Iterable<T>, Page<T>, Slice<T>

@DefaultImplementation(io.micronaut.data.model.DefaultCursoredPage.class) public interface CursoredPage<T> extends Page<T>
Inspired by the Jakarta's CursoredPage, this models a type that supports pagination operations with cursors.

A CursoredPage is a result set associated with a particular Pageable that includes a calculation of the total size of page of records.

Since:
4.8.0
Author:
Andriy Dmytruk
  • Field Details

  • Method Details

    • hasTotalSize

      boolean hasTotalSize()
      Specified by:
      hasTotalSize in interface Page<T>
      Returns:
      Whether this CursoredPage contains the total count of the records
      Since:
      4.8.0
    • getTotalSize

      long getTotalSize()
      Get the total count of all the records that can be given by this query. The method may produce a IllegalStateException if the Pageable request did not ask for total size.
      Specified by:
      getTotalSize in interface Page<T>
      Returns:
      The total size of the all records.
    • getTotalPages

      default int getTotalPages()
      Get the total count of pages that can be given by this query. The method may produce a IllegalStateException if the Pageable request did not ask for total size.
      Specified by:
      getTotalPages in interface Page<T>
      Returns:
      The total page of pages
    • hasNext

      default boolean hasNext()
      Description copied from interface: Slice
      Determine whether there is a next page.
      Specified by:
      hasNext in interface Page<T>
      Specified by:
      hasNext in interface Slice<T>
      Returns:
      Whether there exist a next page.
    • hasPrevious

      default boolean hasPrevious()
      Description copied from interface: Slice
      Determine whether there is a previous page.
      Specified by:
      hasPrevious in interface Slice<T>
      Returns:
      Whether there exist a previous page.
    • nextPageable

      default CursoredPageable nextPageable()
      Description copied from interface: Slice
      Create a pageable for querying the next page of data.

      A pageable may be created even if the end of data was reached to accommodate for cases when new data might be added to the repository. Use Slice.hasNext() to verify if you have reached the end.

      Specified by:
      nextPageable in interface Slice<T>
      Returns:
      The next pageable
    • previousPageable

      default CursoredPageable previousPageable()
      Description copied from interface: Slice
      Create a pageable for querying the previous page of data.

      A pageable may be created even if the end of data was reached to accommodate for cases when new data might be added to the repository. Use Slice.hasPrevious() to verify if you have reached the end.

      Specified by:
      previousPageable in interface Slice<T>
      Returns:
      The previous pageable
    • map

      @NonNull default <T2> @NonNull CursoredPage<T2> map(Function<T,T2> function)
      Maps the content with the given function.
      Specified by:
      map in interface Page<T>
      Specified by:
      map in interface Slice<T>
      Type Parameters:
      T2 - The type returned by the function
      Parameters:
      function - The function to apply to each element in the content.
      Returns:
      A new slice with the mapped content
    • of

      @NonNull static <T> @NonNull CursoredPage<T> of(@NonNull @NonNull List<T> content, @NonNull @NonNull Pageable pageable, @Nullable @Nullable List<Pageable.Cursor> cursors, @Nullable @Nullable Long totalSize)
      Creates a cursored page from the given content, pageable, cursors and totalSize.
      Type Parameters:
      T - The generic type
      Parameters:
      content - The content
      pageable - The pageable
      cursors - The cursors for cursored pagination
      totalSize - The total size
      Returns:
      The slice
    • getCursor

      Optional<Pageable.Cursor> getCursor(int i)
      Get cursor at the given position or empty if no such cursor exists. There must be a cursor for each of the data entities in the same order. To start pagination after or before a cursor create a pageable from it using the same sorting as before.
      Parameters:
      i - The index of cursor to retrieve.
      Returns:
      The cursor at the provided index.
    • getCursors

      List<Pageable.Cursor> getCursors()
      Get all the cursors.
      Returns:
      All the cursors
      See Also:
    • empty

      @NonNull static <T2> @NonNull CursoredPage<T2> empty()
      Creates an empty page object.
      Type Parameters:
      T2 - The generic type
      Returns:
      The slice