Simplify creation of PagedIterables from requests

This commit is contained in:
Liam Newman
2019-10-06 18:45:22 -07:00
parent 29e147f992
commit f28edbcf8f
24 changed files with 334 additions and 636 deletions

View File

@@ -91,15 +91,10 @@ public class GHCommitQueryBuilder {
* Lists up the commits with the criteria built so far.
*/
public PagedIterable<GHCommit> list() {
return new PagedIterable<GHCommit>() {
public PagedIterator<GHCommit> _iterator(int pageSize) {
return new PagedIterator<GHCommit>(req.asIterator(repo.getApiTailUrl("commits"), GHCommit[].class, pageSize)) {
protected void wrapUp(GHCommit[] page) {
for (GHCommit c : page)
c.wrapUp(repo);
}
};
}
};
return req
.asPagedIterable(
repo.getApiTailUrl("commits"),
GHCommit[].class,
item -> item.wrapUp(repo) );
}
}