com.silanis.esl.sdk.Page Maven / Gradle / Ivy
package com.silanis.esl.sdk;
import java.util.Iterator;
import java.util.List;
/**
* User: dave
*/
public class Page implements Iterable {
private final PageRequest request;
private int totalElements;
private List results;
public Page( List results, int totalElements, PageRequest request ) {
this.request = request;
this.totalElements = totalElements;
this.results = results;
}
public int getSize() {
return request.getPageSize();
}
public int getNumberOfElements() {
return results.size();
}
public int getTotalElements() {
return totalElements;
}
public boolean hasNextPage() {
return (request.getFrom() + request.getPageSize() ) <= totalElements;
}
public PageRequest getNextRequest() {
return hasNextPage() ? request.next() : null ;
}
public List getResults() {
return results;
}
@Override
public Iterator iterator() {
return results.iterator();
}
}