T - the GitLab4J type contained in the List.public class Pager<T> extends java.lang.Object implements java.util.Iterator<java.util.List<T>>, Constants
This class defines an Iterator implementation that is used as a paging iterator for all API methods that return a List of objects. It hides the details of interacting with the GitLab API when paging is involved simplifying accessing large lists of objects.
Example usage:
// Get a Pager instance that will page through the projects with 10 projects per page
Pager<Project> projectPager = gitlabApi.getProjectsApi().getProjectsPager(10);
// Iterate through the pages and print out the name and description
while (projectsPager.hasNext())) {
List<Project> projects = projectsPager.next();
for (Project project : projects) {
System.out.println(project.getName() + " : " + project.getDescription());
}
}
Constants.ActionType, Constants.ApplicationScope, Constants.ArchiveFormat, Constants.AutoDevopsDeployStrategy, Constants.BuildGitStrategy, Constants.CommitBuildState, Constants.ContributorOrderBy, Constants.DefaultBranchProtectionLevel, Constants.DeploymentOrderBy, Constants.DeploymentStatus, Constants.DeployTokenScope, Constants.Encoding, Constants.EpicOrderBy, Constants.EventScope, Constants.GroupOrderBy, Constants.GroupSearchScope, Constants.ImpersonationState, Constants.IssueOrderBy, Constants.IssueScope, Constants.IssueState, Constants.JobScope, Constants.LineType, Constants.MergeRequestOrderBy, Constants.MergeRequestScope, Constants.MergeRequestSearchIn, Constants.MergeRequestState, Constants.MilestoneState, Constants.PackageOrderBy, Constants.PackageStatus, Constants.PipelineOrderBy, Constants.PipelineScope, Constants.ProjectAccessTokenScope, Constants.ProjectCreationLevel, Constants.ProjectOrderBy, Constants.ProjectSearchScope, Constants.SearchScope, Constants.SortOrder, Constants.SquashOption, Constants.StateEvent, Constants.SubgroupCreationLevel, Constants.TagOrderBy, Constants.TargetType, Constants.TodoAction, Constants.TodoState, Constants.TodoType, Constants.TokenTypeNEXT_PAGE_HEADER, PAGE_HEADER, PAGE_PARAM, PER_PAGE, PER_PAGE_PARAM, PREV_PAGE_HEADER, TOTAL_HEADER, TOTAL_PAGES_HEADER| Constructor and Description |
|---|
Pager(AbstractApi api,
java.lang.Class<T> type,
int itemsPerPage,
javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> queryParams,
java.lang.Object... pathArgs)
Creates a Pager instance to access the API through the specified path and query parameters.
|
| Modifier and Type | Method and Description |
|---|---|
java.util.List<T> |
all()
Gets all the items from each page as a single List instance.
|
java.util.List<T> |
current()
Returns the current page of List.
|
java.util.List<T> |
first()
Returns the first page of List.
|
int |
getCurrentPage()
Get the current page of the iteration.
|
int |
getItemsPerPage()
Get the items per page value.
|
int |
getTotalItems()
Get the total number of items (T instances) returned by the GitLab API.
|
int |
getTotalPages()
Get the total number of pages returned by the GitLab API.
|
boolean |
hasNext()
Returns the true if there are additional pages to iterate over, otherwise returns false.
|
java.util.List<T> |
last()
Returns the last page of List.
|
java.util.stream.Stream<T> |
lazyStream()
Creates a Stream instance for lazily streaming items from the GitLab server.
|
java.util.List<T> |
next()
Returns the next List in the iteration containing the next page of objects.
|
java.util.List<T> |
page(int pageNumber)
Returns the specified page of List.
|
java.util.List<T> |
previous()
Returns the previous page of List.
|
void |
remove()
This method is not implemented and will throw an UnsupportedOperationException if called.
|
java.util.stream.Stream<T> |
stream()
Builds and returns a Stream instance which is pre-populated with all items from all pages.
|
public Pager(AbstractApi api, java.lang.Class<T> type, int itemsPerPage, javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> queryParams, java.lang.Object... pathArgs) throws GitLabApiException
api - the AbstractApi implementation to communicate throughtype - the GitLab4J type that will be contained in the ListitemsPerPage - items per pagequeryParams - HTTP query paramspathArgs - HTTP path argumentsGitLabApiException - if any error occurspublic int getItemsPerPage()
public int getTotalPages()
public int getTotalItems()
public int getCurrentPage()
public boolean hasNext()
hasNext in interface java.util.Iterator<java.util.List<T>>public java.util.List<T> next()
next in interface java.util.Iterator<java.util.List<T>>java.util.NoSuchElementException - if the iteration has no more elementsjava.lang.RuntimeException - if a GitLab API error occurs, will contain a wrapped GitLabApiException with the details of the errorpublic void remove()
remove in interface java.util.Iterator<java.util.List<T>>java.lang.UnsupportedOperationException - when invokedpublic java.util.List<T> first()
public java.util.List<T> last() throws GitLabApiException
GitLabApiException - if any error occurspublic java.util.List<T> previous()
public java.util.List<T> current()
public java.util.List<T> page(int pageNumber)
pageNumber - the page to getjava.util.NoSuchElementException - if the iteration has no more elementsjava.lang.RuntimeException - if a GitLab API error occurs, will contain a wrapped GitLabApiException with the details of the errorpublic java.util.List<T> all() throws GitLabApiException
GitLabApiException - if any error occurspublic java.util.stream.Stream<T> stream() throws GitLabApiException, java.lang.IllegalStateException
java.lang.IllegalStateException - if Stream has already been issuedGitLabApiException - if any other error occurspublic java.util.stream.Stream<T> lazyStream() throws java.lang.IllegalStateException
java.lang.IllegalStateException - if Stream has already been issued