46 lines
902 B
Java
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();
|
|
}
|
|
|
|
} |