Package org.pipservices3.commons.data
Class DataPage<T>
java.lang.Object
org.pipservices3.commons.data.DataPage<T>
- Type Parameters:
T
- class type
Data transfer object that is used to pass results of paginated queries.
It contains items of retrieved page and optional total number of items.
Most often this object type is used to send responses to paginated queries.
Pagination parameters are defined by PagingParams
object.
The skip
parameter in the PagingParams
there means how many items to skip.
The takes
parameter sets number of items to return in the page.
And the optional total
parameter tells to return total number of items in the query.
Remember: not all implementations support total
parameter
because its generation may lead to severe performance implications.
### Example ###
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());
};
);
- See Also:
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
DataPage
public DataPage() -
DataPage
Creates a new instance of data page and assigns its values.- Parameters:
data
- a list of items from the retrieved page.
-
DataPage
Creates a new instance of data page and assigns its values.- Parameters:
data
- a list of items from the retrieved page.total
- (optional) .
-
-
Method Details
-
getTotal
-
setTotal
-
getData
-
setData
-