Package org.kohsuke.github
Class PagedIterable<T>
- 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
public abstract class PagedIterable<T> extends Object implements Iterable<T>
Iterablethat returnsPagedIterator.PagedIterableis thread-safe butPagedIteratoris not. Any one instance ofPagedIteratorshould only be called from a single thread.- Author:
- Kohsuke Kawaguchi
-
-
Constructor Summary
Constructors Constructor Description PagedIterable()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract PagedIterator<T>_iterator(int pageSize)Iterator over page items.List<T>asList()Deprecated.UsetoList()instead.Set<T>asSet()Deprecated.UsetoSet()instead.PagedIterator<T>iterator()Returns an iterator over elements of typeT.T[]toArray()Eagerly walkIterableand return the result in an array.protected T[]toArray(PagedIterator<T> iterator)Eagerly walkPagedIteratorand return the result in an array.List<T>toList()Eagerly walkIterableand return the result in a list.Set<T>toSet()Eagerly walkIterableand return the result in a set.PagedIterable<T>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
-
-
-
-
Method Detail
-
withPageSize
public PagedIterable<T> withPageSize(int size)
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
@Nonnull public final PagedIterator<T> iterator()
Returns an iterator over elements of typeT.
-
_iterator
@Nonnull public abstract PagedIterator<T> _iterator(int pageSize)
Iterator over page items.- Parameters:
pageSize- the page size- Returns:
- the paged iterator
-
toArray
protected T[] toArray(PagedIterator<T> iterator) throws IOException
Eagerly walkPagedIteratorand return the result in an array.- Parameters:
iterator- thePagedIteratorto read- Returns:
- an array of all elements from the
PagedIterator - Throws:
IOException- if an I/O exception occurs.
-
toArray
@Nonnull public T[] toArray() throws IOException
Eagerly walkIterableand return the result in an array.- Returns:
- the list
- Throws:
IOException- if an I/O exception occurs.
-
toList
@Nonnull public List<T> toList() throws IOException
Eagerly walkIterableand return the result in a list.- Returns:
- the list
- Throws:
IOException- if an I/O Exception occurs
-
toSet
@Nonnull public Set<T> toSet() throws IOException
Eagerly walkIterableand return the result in a set.- Returns:
- the set
- Throws:
IOException- if an I/O Exception occurs
-
asList
@Nonnull @Deprecated public List<T> asList()
Deprecated.UsetoList()instead.Eagerly walkIterableand return the result in a list.- Returns:
- the list
-
-