Data transfer object that is used to pass the results of a paginated query. This object contains items of the retrieved page.
Description
The DataPage class allows you to create a data transfer object that can be used to pass the results of a paginated query. This object contains items of the retrieved page.
Important points
- Most often, this object type is used to send responses to paginated queries.
- Pagination parameters are defined by a PagingParams object.
- The skip parameter in the PagingParams indicates how many items to skip.
- The takes parameter sets number of items to return in the page.
- An optional total paramter allows you to specify the total number of items returned from a request. However, not all implementations support the total parameter because its generation may lead to severe performance implications.
Constructors
Creates a new instance of DataPage and assigns its values.
public
DataPage(Listdata, Long total)
- data: List
- list of items from the retrieved page. - total: Long - total amount of items in a request.
Fields
### Instance methodsgetTotal
Total.
public
Long getTotal()
- returns: Long - total.
SetTotal
Total.
public
setTotal(Long value)
- value: Long - total.
getData
Data.
public
ListgetData()
- returns: List
- data.
SetData
Data.
public
setData(Listvalue)
- value: List
- total.
Examples
{
myDataClient.getDataByFilter(
"123",
FilterParams.fromTuples("completed", true),
new PagingParams(0, 100, true),
(DataPage<MyData> page) -> {
System.out.println("Items: ");
for (MyData item : page.getData()) {
System.out.println(item);
}
System.out.println("Total items: " + page.getTotal());
};
);
}