001package org.gbif.api.util.iterables;
002
003import org.gbif.api.model.common.paging.PagingRequest;
004import org.gbif.api.model.common.paging.PagingResponse;
005import org.gbif.api.model.registry.Dataset;
006import org.gbif.api.service.registry.NetworkService;
007import org.gbif.api.vocabulary.DatasetType;
008
009import java.util.UUID;
010import javax.annotation.Nullable;
011
012/**
013 * Iterates over all datasets belonging to a given network.
014 */
015public class NetworkPager extends DatasetBasePager {
016
017    private final NetworkService service;
018    private final UUID key;
019
020    public NetworkPager(NetworkService service, UUID key, @Nullable DatasetType type, int pageSize) {
021        super(type, pageSize);
022        this.service = service;
023        this.key = key;
024    }
025
026    @Override
027    PagingResponse<Dataset> nextPage(PagingRequest page) {
028        return service.listConstituents(key, page);
029    }
030
031}