Interface Page<T>

Type Parameters:
T - The generic type
All Superinterfaces:
Iterable<T>, Slice<T>
All Known Subinterfaces:
CursoredPage<T>

@DefaultImplementation(io.micronaut.data.model.DefaultPage.class) public interface Page<T> extends Slice<T>
One page of query results: the records selected by a particular Pageable (page number, page size and sort order), together with the total number of records matching the query, from which the total number of pages is calculated. Computing the total usually requires an additional count query; use Slice when it is not needed.

Similar to Spring Data's Page and GORM's PagedResultList.

Since:
1.0.0
Author:
graemerocher
  • Field Details

    • EMPTY

      static final Page<?> EMPTY
  • Method Details

    • hasTotalSize

      boolean hasTotalSize()
      Returns:
      Whether this Page 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. For EMPTY page the value is -1.
      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.
      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 Slice<T>
      Returns:
      Whether there exist a next page.
    • map

      default <T2> Page<T2> map(Function<T,T2> function)
      Maps the content with the given function.
      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

      static <T> Page<T> of(List<T> content, Pageable pageable, @Nullable Long totalSize)
      Creates a page from the given content, pageable and totalSize.
      Type Parameters:
      T - The generic type
      Parameters:
      content - The content
      pageable - The pageable
      totalSize - The total size
      Returns:
      The slice
    • ofCursors

      @Internal static <T> Page<T> ofCursors(List<T> content, Pageable pageable, @Nullable List<Pageable.Cursor> cursors, @Nullable Long totalSize)
      Creates a page from the given content, pageable, cursors and totalSize. This method is for JSON deserialization. Please use CursoredPage.of(List, Pageable, List, Long) instead.
      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
    • empty

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