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

com.greenback.kit.model.Paginated Maven / Gradle / Ivy

There is a newer version: 1.0.39
Show newest version
package com.greenback.kit.model;

import java.util.Iterator;
import java.util.List;
import static java.util.Optional.ofNullable;

public class Paginated extends Response implements Iterable {
 
    private Pagination pagination;
    private List values;
    
    public Pagination getPagination() {
        return pagination;
    }

    public void setPagination(Pagination pagination) {
        this.pagination = pagination;
    }

    public List getValues() {
        return values;
    }

    public void setValues(List values) {
        this.values = values;
    }
    
    public String getNext() {
        return ofNullable(this.pagination)
            .map(v -> v.getNext())
            .orElse(null);
    }
    
    public boolean hasNext() {
        return ofNullable(this.pagination)
            .map(v -> v.getNext())
            .isPresent();
    }

    @Override
    public Iterator iterator() {
        return this.getValues().iterator();
    }
    
    
    static public  long getTotalCount(Paginated paginated) {
        return ofNullable(paginated)
            .map(v -> v.getPagination())
            .map(v -> v.getTotalCount())
            .orElse(0L);
    }
    
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy