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.ApplicationScope, Constants.ArchiveFormat, Constants.CommitBuildState, Constants.DeploymentStatus, Constants.DeployTokenScope, Constants.Encoding, Constants.EpicOrderBy, 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.PipelineOrderBy, Constants.PipelineScope, Constants.ProjectOrderBy, Constants.ProjectSearchScope, Constants.SearchScope, Constants.SortOrder, Constants.StateEvent, Constants.TagOrderBy, Constants.TargetType, Constants.TodoAction, Constants.TodoState, Constants.TodoType, Constants.TokenType
NEXT_PAGE_HEADER, PAGE_HEADER, PAGE_PARAM, PER_PAGE, PER_PAGE_PARAM, PREV_PAGE_HEADER, TOTAL_HEADER, TOTAL_PAGES_HEADER
Modifier and Type | Method and Description |
---|---|
List<T> |
all()
Gets all the items from each page as a single List instance.
|
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.
|
Stream<T> |
lazyStream()
Creates a Stream instance for lazily streaming items from the GitLab server.
|
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.
|
Stream<T> |
stream()
Builds and returns a Stream instance which is pre-populated with all items from all pages.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
public int getItemsPerPage()
public int getTotalPages()
public int getTotalItems()
public int getCurrentPage()
public boolean hasNext()
public List<T> next()
next
in interface Iterator<List<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<List<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 errorpublic List<T> all() throws GitLabApiException
GitLabApiException
- if any error occurspublic Stream<T> stream() throws GitLabApiException, IllegalStateException
IllegalStateException
- if Stream has already been issuedGitLabApiException
- if any other error occurspublic Stream<T> lazyStream() throws IllegalStateException
IllegalStateException
- if Stream has already been issuedCopyright © 2020. All rights reserved.