T
- Type of iterable objectspublic final class Bulk<T extends JsonReadable> extends Object implements Iterable<T>
This class should be used as a decorator for object obtained from Github, when you want to keep their JSON values in memory. For example:
Iterable<Issue> issues = repo.issues().iterate( new HashMap<String, String>() ); for (Issue issue : issues) { System.out.println(new Issue.Smart(issue).title()); }
Let's say, there are 50 issues in Github's repo. This code will make 52 HTTP requests to Github. The first one will fetch the first 30 issues in JSON array. Then, for every one of them, in order to retrieve issue title a separate HTTP request will be made. Then, one more page will be fetched, with 20 issues. And again, 20 new HTTP requests to get their titles.
Class Bulk
helps us to reduce the amount of this extra work:
Iterable<Issue> issues = new Bulk<Issue>( repo.issues().iterate( new HashMap<String, String>() ) );
Now, there will be just two HTTP requests.
Copyright © 2012–2014 jcabi.com. All rights reserved.