Record Class PaginationDTO
java.lang.Object
java.lang.Record
com.endurancetrio.business.common.dto.PaginationDTO
- Record Components:
pageNumber- the 0-based current page numbertotalPages- the total number of pagestotalItems- the total number of items across all pageshasPrevious- whether a previous page existshasNext- 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
ConstructorsConstructorDescriptionPaginationDTO(int pageNumber, int totalPages, long totalItems, boolean hasPrevious, boolean hasNext) Creates an instance of aPaginationDTOrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.static <T> PaginationDTOfrom(org.springframework.data.domain.Page<T> page) Creates aPaginationDTOfrom a Spring DataPage.final inthashCode()Returns a hash code value for this object.booleanhasNext()Returns the value of thehasNextrecord component.booleanReturns the value of thehasPreviousrecord component.intReturns the value of thepageNumberrecord component.final StringtoString()Returns a string representation of this record class.longReturns the value of thetotalItemsrecord component.intReturns the value of thetotalPagesrecord component.
-
Constructor Details
-
PaginationDTO
public PaginationDTO(int pageNumber, int totalPages, long totalItems, boolean hasPrevious, boolean hasNext) Creates an instance of aPaginationDTOrecord class.- Parameters:
pageNumber- the value for thepageNumberrecord componenttotalPages- the value for thetotalPagesrecord componenttotalItems- the value for thetotalItemsrecord componenthasPrevious- the value for thehasPreviousrecord componenthasNext- the value for thehasNextrecord component
-
-
Method Details
-
from
Creates aPaginationDTOfrom a Spring DataPage.- Type Parameters:
T- the content type of the page- Parameters:
page- the Spring DataPageto derive values from- Returns:
- a new
PaginationDTOwith the pagination state of the givenPage
-
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. -
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. -
equals
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 '=='. -
pageNumber
public int pageNumber()Returns the value of thepageNumberrecord component.- Returns:
- the value of the
pageNumberrecord component
-
totalPages
public int totalPages()Returns the value of thetotalPagesrecord component.- Returns:
- the value of the
totalPagesrecord component
-
totalItems
public long totalItems()Returns the value of thetotalItemsrecord component.- Returns:
- the value of the
totalItemsrecord component
-
hasPrevious
public boolean hasPrevious()Returns the value of thehasPreviousrecord component.- Returns:
- the value of the
hasPreviousrecord component
-
hasNext
public boolean hasNext()Returns the value of thehasNextrecord component.- Returns:
- the value of the
hasNextrecord component
-