org.kohsuke.github.GHWorkflowJobsIterable Maven / Gradle / Ivy
package org.kohsuke.github;
import java.util.Iterator;
import javax.annotation.Nonnull;
// TODO: Auto-generated Javadoc
/**
* Iterable for workflow run jobs listing.
*/
class GHWorkflowJobsIterable extends PagedIterable {
private final GHRepository repo;
private final GitHubRequest request;
private GHWorkflowJobsPage result;
/**
* Instantiates a new GH workflow jobs iterable.
*
* @param repo
* the repo
* @param request
* the request
*/
public GHWorkflowJobsIterable(GHRepository repo, GitHubRequest request) {
this.repo = repo;
this.request = request;
}
/**
* Iterator.
*
* @param pageSize
* the page size
* @return the paged iterator
*/
@Nonnull
@Override
public PagedIterator _iterator(int pageSize) {
return new PagedIterator<>(
adapt(GitHubPageIterator.create(repo.root().getClient(), GHWorkflowJobsPage.class, request, pageSize)),
null);
}
/**
* Adapt.
*
* @param base
* the base
* @return the iterator
*/
protected Iterator adapt(final Iterator base) {
return new Iterator() {
public boolean hasNext() {
return base.hasNext();
}
public GHWorkflowJob[] next() {
GHWorkflowJobsPage v = base.next();
if (result == null) {
result = v;
}
return v.getWorkflowJobs(repo);
}
};
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy