package com.reljicd.util; import com.reljicd.model.Product; import org.springframework.data.domain.Page; /** * @author Dusan Raljic */ public class Pager { private final Page products; public Pager(Page products) { this.products = products; } public int getPageIndex() { return products.getNumber() + 1; } public int getPageSize() { return products.getSize(); } public boolean hasNext() { return products.hasNext(); } public boolean hasPrevious() { return products.hasPrevious(); } public int getTotalPages() { return products.getTotalPages(); } public long getTotalElements() { return products.getTotalElements(); } public boolean indexOutOfBounds() { return this.getPageIndex() < 0 || this.getPageIndex() > this.getTotalElements(); } }