T - the GitLab4J type contained in the List.public class Pager<T> extends Object implements Iterator<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.EpicOrderBy, Constants.GroupOrderBy, Constants.ImpersonationState, Constants.IssueScope, Constants.IssueState, Constants.JobScope, Constants.LineType, Constants.MergeRequestOrderBy, Constants.MergeRequestScope, Constants.MergeRequestState, Constants.MilestoneState, Constants.PipelineOrderBy, Constants.PipelineScope, Constants.ProjectOrderBy, Constants.SortOrder, Constants.StateEvent, Constants.TargetType, Constants.TokenTypeNEXT_PAGE_HEADER, PAGE_HEADER, PAGE_PARAM, PER_PAGE, PER_PAGE_PARAM, PREV_PAGE_HEADER, TOTAL_HEADER, TOTAL_PAGES_HEADER| Modifier and Type | Method | Description |
|---|---|---|
List<T> |
current() |
Returns the current page of List.
|
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.
|
List<T> |
last() |
Returns the last page of List.
|
List<T> |
next() |
Returns the next List in the iteration containing the next page of objects.
|
List<T> |
page(int pageNumber) |
Returns the specified page of List.
|
List<T> |
previous() |
Returns the previous page of List.
|
void |
remove() |
This method is not implemented and will throw an UnsupportedOperationException if called.
|
forEachRemainingpublic int getItemsPerPage()
public int getTotalPages()
public int getTotalItems()
public int getCurrentPage()
public boolean hasNext()
public List<T> next()
next in interface Iterator<T>NoSuchElementException - if the iteration has no more elementsRuntimeException - if a GitLab API error occurs, will contain a wrapped GitLabApiException with the details of the errorpublic void remove()
remove in interface Iterator<T>UnsupportedOperationException - when invokedpublic List<T> first() throws GitLabApiException
GitLabApiException - if any error occurspublic List<T> last() throws GitLabApiException
GitLabApiException - if any error occurspublic List<T> previous() throws GitLabApiException
GitLabApiException - if any error occurspublic List<T> current() throws GitLabApiException
GitLabApiException - if any error occurspublic List<T> page(int pageNumber)
pageNumber - the page to getNoSuchElementException - if the iteration has no more elementsRuntimeException - if a GitLab API error occurs, will contain a wrapped GitLabApiException with the details of the errorCopyright © 2018. All rights reserved.