Class PagingRequest

java.lang.Object
org.kiwiproject.spring.data.PagingRequest
All Implemented Interfaces:
PagingParams

public class PagingRequest extends Object implements PagingParams
Jakarta REST based implementation of PagingParams.

Intended to be used in Jakarta REST resource classes with HTTP GET endpoint methods having an argument annotated with BeanParam.

Example:

 @GET
  public Response page(@BeanParam PagingRequest pagingRequest) {
     // ...
  }
 
Implementation Note:
Requires Spring Data Commons and the Jakarta REST API to be available at runtime.
  • Field Details

  • Constructor Details

    • PagingRequest

      public PagingRequest()
  • Method Details

    • copyOf

      public static PagingRequest copyOf(PagingRequest original)
      Create a copy of the given PagingRequest.
      Parameters:
      original - the object to copy
      Returns:
      a new instance containing the same values as original
      Throws:
      IllegalArgumentException - if original is null
    • copyOf

      public PagingRequest copyOf()
      Create a copy of this instance.
      Returns:
      a new instance containing the same values as this
    • ensurePaginationProperties

      public static boolean ensurePaginationProperties(PagingRequest request)
      Ensure the given PagingRequest has pagination properties by providing default values for any null or invalid properties.

      Note specifically that this mutates the request argument in-place. You can use either the instance or static withPaginationProperties method to create a new instance with valid pagination properties to avoid mutation of the original PagingRequest instance.

      Parameters:
      request - the PagingRequest to check; this argument may be mutated in-place
      Returns:
      true if request was mutated, otherwise false
    • withPaginationProperties

      public static PagingRequest withPaginationProperties(PagingRequest request)
      Ensure the given PagingRequest has pagination properties by providing default values for any null or invalid properties, returning the same instance if it is valid, and otherwise returning a new instance.
      Parameters:
      request - the request to check
      Returns:
      request if it contains pagination properties, otherwise a new instance with valid values for the missing properties
    • withPaginationProperties

      public PagingRequest withPaginationProperties()
      Ensure the given PagingRequest has pagination properties by providing default values for any null or invalid properties.
      Returns:
      this instance if it contains pagination properties, otherwise a new instance with valid values for the missing properties
    • getPage

      public Integer getPage()
      The page number. Default is zero.

      Note this does not preclude using either zero or one-based page numbering, but other classes may require one or the other page numbering scheme.

      Specified by:
      getPage in interface PagingParams
      Returns:
      the page number
    • getNumbering

      public KiwiSearching.PageNumberingScheme getNumbering()
      The page numbering scheme used by this paging request.
      Specified by:
      getNumbering in interface PagingParams
      Returns:
      the numbering scheme used by this instance
    • getLimit

      public Integer getLimit()
      The page size limit. Default is 100.
      Specified by:
      getLimit in interface PagingParams
      Returns:
      the page size limit
    • getPrimarySort

      public String getPrimarySort()
      The primary sort property. Default is null.
      Specified by:
      getPrimarySort in interface PagingParams
      Returns:
      the primary sort property
    • getPrimaryDirection

      public org.springframework.data.domain.Sort.Direction getPrimaryDirection()
      The primary sort direction. Default is ascending (ASC).

      This is only relevant if a primarySort has been specified.

      Specified by:
      getPrimaryDirection in interface PagingParams
      Returns:
      the primary sort direction
    • getSecondarySort

      public String getSecondarySort()
      The secondary sort property. Default is null.
      Specified by:
      getSecondarySort in interface PagingParams
      Returns:
      the secondary sort property
    • getSecondaryDirection

      public org.springframework.data.domain.Sort.Direction getSecondaryDirection()
      The secondary sort direction. Default is ascending (ASC).

      This is only relevant if a secondarySort has been specified.

      Specified by:
      getSecondaryDirection in interface PagingParams
      Returns:
      the secondary sort direction
    • setPage

      public void setPage(Integer page)
      The page number. Default is zero.

      Note this does not preclude using either zero or one-based page numbering, but other classes may require one or the other page numbering scheme.

      Specified by:
      setPage in interface PagingParams
      Parameters:
      page - the page number
    • setNumbering

      public void setNumbering(KiwiSearching.PageNumberingScheme numbering)
      The page numbering scheme used by this paging request.
      Specified by:
      setNumbering in interface PagingParams
      Parameters:
      numbering - the numbering scheme this instance should use
    • setLimit

      public void setLimit(Integer limit)
      The page size limit. Default is 100.
      Specified by:
      setLimit in interface PagingParams
      Parameters:
      limit - the page size limit
    • setPrimarySort

      public void setPrimarySort(String primarySort)
      The primary sort property. Default is null.
      Specified by:
      setPrimarySort in interface PagingParams
      Parameters:
      primarySort - the primary sort property
    • setPrimaryDirection

      public void setPrimaryDirection(org.springframework.data.domain.Sort.Direction primaryDirection)
      The primary sort direction. Default is ascending (ASC).

      This is only relevant if a primarySort has been specified.

      Specified by:
      setPrimaryDirection in interface PagingParams
      Parameters:
      primaryDirection - the primary sort direction
    • setSecondarySort

      public void setSecondarySort(String secondarySort)
      The secondary sort property. Default is null.
      Specified by:
      setSecondarySort in interface PagingParams
      Parameters:
      secondarySort - the secondary sort property
    • setSecondaryDirection

      public void setSecondaryDirection(org.springframework.data.domain.Sort.Direction secondaryDirection)
      The secondary sort direction. Default is ascending (ASC).

      This is only relevant if a secondarySort has been specified.

      Specified by:
      setSecondaryDirection in interface PagingParams
      Parameters:
      secondaryDirection - the secondary sort direction
    • toString

      public String toString()
      Overrides:
      toString in class Object