Record Class PageResult<T>
java.lang.Object
java.lang.Record
com.vertyll.freshly.lang.page.PageResult<T>
- Type Parameters:
T- a domain model
One page as a repository hands it back.
Paired with PagedResponse, which is what a query use case returns. The split
is deliberate: this one holds domain models and has whatever shape paging needs, that
one holds DTOs and has the shape the API promises. Collapsing them would make the
storage adapter's convenience into the client's contract.
So this type should not appear above a repository port. PagedResponse.from
is the crossing point, and the only place both are named.
-
Constructor Summary
ConstructorsConstructorDescriptionPageResult(List<T> content, int page, int size, long totalElements) Creates an instance of aPageResultrecord class. -
Method Summary
Modifier and TypeMethodDescriptioncontent()Returns the value of thecontentrecord component.static <T> PageResult<T> empty(PageRequest request) final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.<R> PageResult<R> Maps the content while keeping the paging metadata, so an adapter can turn a page of domain models into a page of DTOs without restating the counts.intpage()Returns the value of thepagerecord component.intsize()Returns the value of thesizerecord component.final StringtoString()Returns a string representation of this record class.longReturns the value of thetotalElementsrecord component.int
-
Constructor Details
-
PageResult
Creates an instance of aPageResultrecord class.- Parameters:
content- the value for thecontentrecord componentpage- the value for thepagerecord componentsize- the value for thesizerecord componenttotalElements- the value for thetotalElementsrecord component
-
-
Method Details
-
empty
-
totalPages
public int totalPages() -
map
Maps the content while keeping the paging metadata, so an adapter can turn a page of domain models into a page of DTOs without restating the counts. -
toString
-
hashCode
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
content
-
page
public int page()Returns the value of thepagerecord component.- Returns:
- the value of the
pagerecord component
-
size
public int size()Returns the value of thesizerecord component.- Returns:
- the value of the
sizerecord component
-
totalElements
public long totalElements()Returns the value of thetotalElementsrecord component.- Returns:
- the value of the
totalElementsrecord component
-