public interface IPageable {
int getCurrentPage();
default int getOffsetPage() {
return (getCurrentPage() - 1) * getItemsPerPage();
}
default int getOffset() {
return getOffsetPage();
}
void setCurrentPage(int currentPage);
int getItemsPerPage();
void setItemsPerPage(int itemsPerPage);
default int getLimit() {
return getItemsPerPage();
}
}
public class Pageable implements IPageable {
private int currentPage;
private int itemsPerPage;
@Override
public int getCurrentPage() {
return currentPage;
}
@Override
public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
}
@Override
public int getItemsPerPage() {
return itemsPerPage;
}
@Override
public void setItemsPerPage(int itemsPerPage) {
this.itemsPerPage = itemsPerPage;
}
}
public class PageableJO<JO> extends Pageable {
JO filter;
public JO getFilter() {
return filter;
}
public void setFilter(JO filter) {
this.filter = filter;
}
}