Doub allows you to build an object pager with different origins. The main functionality is to provide a common pagination between the objects managed by different processes, distributing the requisition of resources in an intelligent way.
- Add to pom.xml file
<dependency>
<groupId>io.github.mariomatheus</groupId>
<artifactId>doub</artifactId>
<version>0.0.2</version>
</dependency>- Install dependency
mvn installTo build the pagination, it is necessary to provide two resources to the
Pagination object through the put method, the total number of
elements managed by the process and a function to request these elements
through the limit and offset parameters that will be
calculated internally and used as arguments of this function for the data
recovery.
Pagination<FooBar> pagination = new Pagination<>()
.put(fooTotalElements, (offset, limit) -> repository.findFooByOffsetAndLimit(offset, limit))
.put(barTotalElements, (offset, limit) -> service.requestBarByOffsetAndLimit(offset, limit));After the construction of the Pagination object, the paginate
function is used to request the objects in a unified and transparent way.
List<FooBar> content = pagination
.paginate(0, 10)
.getContent();See more details in Apache LICENSE.
