java.lang.Object
org.kohsuke.github.PagedIterable<T>
- Type Parameters:
T
- the type of items on each page
- All Implemented Interfaces:
Iterable<T>
- Direct Known Subclasses:
PagedSearchIterable
Iterable
that returns PagedIterator
. PagedIterable
is thread-safe but PagedIterator
is not. Any one instance of PagedIterator
should only be called from a single thread.- Author:
- Kohsuke Kawaguchi
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract PagedIterator<T>
_iterator
(int pageSize) Iterator over page items.final PagedIterator<T>
iterator()
Returns an iterator over elements of typeT
.T[]
toArray()
Eagerly walkIterable
and return the result in an array.protected T[]
toArray
(PagedIterator<T> iterator) Eagerly walkPagedIterator
and return the result in an array.toList()
Eagerly walkIterable
and return the result in a list.toSet()
Eagerly walkIterable
and return the result in a set.withPageSize
(int size) Sets the pagination size.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
PagedIterable
public PagedIterable()Instantiate a PagedIterable.
-
-
Method Details
-
withPageSize
Sets the pagination size.When set to non-zero, each API call will retrieve this many entries.
- Parameters:
size
- the size- Returns:
- the paged iterable
-
iterator
Returns an iterator over elements of typeT
. -
_iterator
Iterator over page items.- Parameters:
pageSize
- the page size- Returns:
- the paged iterator
-
toArray
Eagerly walkPagedIterator
and return the result in an array.- Parameters:
iterator
- thePagedIterator
to read- Returns:
- an array of all elements from the
PagedIterator
- Throws:
IOException
- if an I/O exception occurs.
-
toArray
Eagerly walkIterable
and return the result in an array.- Returns:
- the list
- Throws:
IOException
- if an I/O exception occurs.
-
toList
Eagerly walkIterable
and return the result in a list.- Returns:
- the list
- Throws:
IOException
- if an I/O Exception occurs
-
toSet
Eagerly walkIterable
and return the result in a set.- Returns:
- the set
- Throws:
IOException
- if an I/O Exception occurs
-