zkt24/Ekart/src/main/java/com/reljicd/util/Pager.java
2024-04-12 10:56:06 +02:00

46 lines
902 B
Java

package com.reljicd.util;
import com.reljicd.model.Product;
import org.springframework.data.domain.Page;
/**
* @author Dusan Raljic
*/
public class Pager {
private final Page<Product> products;
public Pager(Page<Product> 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();
}
}