All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.silanis.esl.sdk.Page Maven / Gradle / Ivy

There is a newer version: 11.59.0
Show newest version
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();
    }
}






© 2015 - 2024 Weber Informatics LLC | Privacy Policy