Massaging the pull request 15.

- we need to maintain the binary compatibility, so I reverted
  getPullRequests and added listPullRequests that exposes PagedIterable.

- Made PagedIterator expose asList.
This commit is contained in:
Kohsuke Kawaguchi
2012-08-28 09:39:49 -07:00
parent 9fd34aec7f
commit 8f95c4f179
5 changed files with 32 additions and 21 deletions

View File

@@ -1,8 +1,24 @@
package org.kohsuke.github;
import java.util.ArrayList;
import java.util.List;
/**
* {@link Iterable} that returns {@link PagedIterator}
*
* @author Kohsuke Kawaguchi
*/
public interface PagedIterable<T> extends Iterable<T> {
PagedIterator<T> iterator();
public abstract class PagedIterable<T> implements Iterable<T> {
public abstract PagedIterator<T> iterator();
/**
* Eagerly walk {@link Iterable} and return the result in a list.
*/
public List<T> asList() {
List<T> r = new ArrayList<T>();
for(PagedIterator<T> i = iterator(); i.hasNext();) {
r.addAll(i.nextPage());
}
return r;
}
}