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.InstallationService;
007import org.gbif.api.vocabulary.DatasetType;
008
009import java.util.UUID;
010import javax.annotation.Nullable;
011
012/**
013 * Iterates over all datasets hosted by a given installation.
014 */
015public class InstallationPager extends DatasetBasePager {
016
017    private final InstallationService service;
018    private final UUID installationKey;
019
020    public InstallationPager(InstallationService service, UUID installationKey,
021                             @Nullable DatasetType type, int pageSize) {
022        super(type, pageSize);
023        this.service = service;
024        this.installationKey = installationKey;
025    }
026
027    @Override
028    PagingResponse<Dataset> nextPage(PagingRequest page) {
029        return service.getHostedDatasets(installationKey, page);
030    }
031
032}