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.Organization;
006import org.gbif.api.service.registry.NodeService;
007
008import java.util.UUID;
009
010/**
011 * Pages through all organizations endorsed by a given node.
012 */
013public class NodeOrganizationPager extends EntityPager<Organization> {
014
015    private final NodeService service;
016    private final UUID endorsingNodeKey;
017
018    public NodeOrganizationPager(NodeService service, UUID endorsingNodeKey, int pageSize) {
019        super(pageSize);
020        this.service = service;
021        this.endorsingNodeKey = endorsingNodeKey;
022    }
023
024    @Override
025    PagingResponse<Organization> nextPage(PagingRequest page) {
026        return service.endorsedOrganizations(endorsingNodeKey, page);
027    }
028
029}