Record Class PaginationDTO

java.lang.Object
java.lang.Record
com.endurancetrio.business.common.dto.PaginationDTO
Record Components:
pageNumber - the 0-based current page number
totalPages - the total number of pages
totalItems - the total number of items across all pages
hasPrevious - whether a previous page exists
hasNext - whether a next page exists

public record PaginationDTO(int pageNumber, int totalPages, long totalItems, boolean hasPrevious, boolean hasNext) extends Record
PaginationDTO is a generic pagination metadata record used to pass pagination state from the service layer to the presentation layer without exposing Spring Data Page directly.
  • Constructor Summary

    Constructors
    Constructor
    Description
    PaginationDTO(int pageNumber, int totalPages, long totalItems, boolean hasPrevious, boolean hasNext)
    Creates an instance of a PaginationDTO record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    static <T> PaginationDTO
    from(org.springframework.data.domain.Page<T> page)
    Creates a PaginationDTO from a Spring Data Page.
    final int
    Returns a hash code value for this object.
    boolean
    Returns the value of the hasNext record component.
    boolean
    Returns the value of the hasPrevious record component.
    int
    Returns the value of the pageNumber record component.
    final String
    Returns a string representation of this record class.
    long
    Returns the value of the totalItems record component.
    int
    Returns the value of the totalPages record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • PaginationDTO

      public PaginationDTO(int pageNumber, int totalPages, long totalItems, boolean hasPrevious, boolean hasNext)
      Creates an instance of a PaginationDTO record class.
      Parameters:
      pageNumber - the value for the pageNumber record component
      totalPages - the value for the totalPages record component
      totalItems - the value for the totalItems record component
      hasPrevious - the value for the hasPrevious record component
      hasNext - the value for the hasNext record component
  • Method Details

    • from

      public static <T> PaginationDTO from(org.springframework.data.domain.Page<T> page)
      Creates a PaginationDTO from a Spring Data Page.
      Type Parameters:
      T - the content type of the page
      Parameters:
      page - the Spring Data Page to derive values from
      Returns:
      a new PaginationDTO with the pagination state of the given Page
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • pageNumber

      public int pageNumber()
      Returns the value of the pageNumber record component.
      Returns:
      the value of the pageNumber record component
    • totalPages

      public int totalPages()
      Returns the value of the totalPages record component.
      Returns:
      the value of the totalPages record component
    • totalItems

      public long totalItems()
      Returns the value of the totalItems record component.
      Returns:
      the value of the totalItems record component
    • hasPrevious

      public boolean hasPrevious()
      Returns the value of the hasPrevious record component.
      Returns:
      the value of the hasPrevious record component
    • hasNext

      public boolean hasNext()
      Returns the value of the hasNext record component.
      Returns:
      the value of the hasNext record component