Class DefaultPageRequest

java.lang.Object
com.broadleafcommerce.data.tracking.core.filtering.DefaultPageRequest
All Implemented Interfaces:
Serializable, org.springframework.data.domain.Pageable

public final class DefaultPageRequest extends Object implements org.springframework.data.domain.Pageable, Serializable
Pageable implementation used to differentiate default PageRequests from specialized Broadleaf use-cases. The usual use-case is to represent a request made with no explicit pagination info. This signals to the NarrowExecutor that this can be safely converted to a NarrowedPageable to fetch the first page or results with the default page size, whereas a PageRequest would indicate that a request with explicit pagination info has been made but the info was too incomplete to create a NarrowedPageable (usually because of a missing offset value), which the NarrowExecutor cannot reliably handle.
Author:
Nathan Moore (nathandmoore)
See Also:
  • Field Details

  • Constructor Details

    • DefaultPageRequest

      public DefaultPageRequest()
      A new page request starting at 0 and containing getDefaultSize() elements
    • DefaultPageRequest

      public DefaultPageRequest(int page, int size)
      A new page request with no sorting
      Parameters:
      page - zero-based page index, must not be negative
      size - The size of the page to be returned, must not be negative. If it is greater than the maximum page size that is gotten from the passed PageableProperties, the PageableProperties configured maximum page size will be used instead
    • DefaultPageRequest

      public DefaultPageRequest(@Nullable Integer page, @Nullable Integer size, @Nullable org.springframework.data.domain.Sort sort)
      A page request that includes sorting
      Parameters:
      page - zero-based page index, must not be negative. If null, defaults to 0
      size - the size of the page to be returned. If null, defaults to getDefaultSize(). If the passed size is greater than the default maximum page size, the default maximum page size will be used instead
      sort - Sort for the request. If null, forced to getDefaultSort().
    • DefaultPageRequest

      public DefaultPageRequest(@Nullable Integer page, @Nullable Integer size, @Nullable org.springframework.data.domain.Sort sort, @Nullable PageableProperties pageableProperties)
      A page request that includes sorting
      Parameters:
      page - zero-based page index, must not be negative. If null, defaults to 0
      size - the size of the page to be returned. If null, defaults to getDefaultSize(). If the passed size is greater than the default maximum page size or the size that is gotten from the passed PageableProperties, the default maximum page size or the PageableProperties configured maximum page size will be used instead
      sort - Sort for the request. If null, forced to getDefaultSort().
      pageableProperties - properties for pageable operations
  • Method Details

    • getMaxSize

      protected int getMaxSize()
      Determines the default max page size allowed. Default is DEFAULT_SIZE.
      Returns:
      the default max page size allowed
    • getDefaultSize

      protected int getDefaultSize()
      Determines the default page size. Default is DEFAULT_SIZE.
      Returns:
      the default page size
    • getDefaultSort

      protected org.springframework.data.domain.Sort getDefaultSort()
      Determines the default Sort. Default is Sort.unsorted().
      Returns:
      the default Sort
    • getPageRequest

      public org.springframework.data.domain.PageRequest getPageRequest()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getSort

      public org.springframework.data.domain.Sort getSort()
      Specified by:
      getSort in interface org.springframework.data.domain.Pageable
    • next

      public org.springframework.data.domain.PageRequest next()
      Specified by:
      next in interface org.springframework.data.domain.Pageable
    • previous

      public org.springframework.data.domain.PageRequest previous()
    • first

      public org.springframework.data.domain.PageRequest first()
      Specified by:
      first in interface org.springframework.data.domain.Pageable
    • withPage

      public org.springframework.data.domain.PageRequest withPage(int pageNumber)
      Specified by:
      withPage in interface org.springframework.data.domain.Pageable
    • withSort

      public org.springframework.data.domain.PageRequest withSort(org.springframework.data.domain.Sort.Direction direction, String... properties)
    • withSort

      public org.springframework.data.domain.PageRequest withSort(org.springframework.data.domain.Sort sort)
    • getPageSize

      public int getPageSize()
      Specified by:
      getPageSize in interface org.springframework.data.domain.Pageable
    • getPageNumber

      public int getPageNumber()
      Specified by:
      getPageNumber in interface org.springframework.data.domain.Pageable
    • getOffset

      public long getOffset()
      Specified by:
      getOffset in interface org.springframework.data.domain.Pageable
    • hasPrevious

      public boolean hasPrevious()
      Specified by:
      hasPrevious in interface org.springframework.data.domain.Pageable
    • previousOrFirst

      public org.springframework.data.domain.Pageable previousOrFirst()
      Specified by:
      previousOrFirst in interface org.springframework.data.domain.Pageable
    • isPaged

      public boolean isPaged()
      Specified by:
      isPaged in interface org.springframework.data.domain.Pageable
    • isUnpaged

      public boolean isUnpaged()
      Specified by:
      isUnpaged in interface org.springframework.data.domain.Pageable
    • getSortOr

      public org.springframework.data.domain.Sort getSortOr(org.springframework.data.domain.Sort sort)
      Specified by:
      getSortOr in interface org.springframework.data.domain.Pageable
    • toOptional

      public Optional<org.springframework.data.domain.Pageable> toOptional()
      Specified by:
      toOptional in interface org.springframework.data.domain.Pageable
    • toScrollPosition

      public org.springframework.data.domain.OffsetScrollPosition toScrollPosition()
      Specified by:
      toScrollPosition in interface org.springframework.data.domain.Pageable