Skip to content

MarioMatheus/doub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Doub - Mux Pagination Library

License Maven Central

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.

Pagination Scheme

Installing

  1. Add to pom.xml file
<dependency>
  <groupId>io.github.mariomatheus</groupId>
  <artifactId>doub</artifactId>
  <version>0.0.2</version>
</dependency>
  1. Install dependency
mvn install

Using

To 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();

License

See more details in Apache LICENSE.

About

Mux Pagination Library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages