Class Bulk<T extends JsonReadable>

  • Type Parameters:
    T - Type of iterable objects
    All Implemented Interfaces:
    Iterable<T>

    public final class Bulk<T extends JsonReadable>
    extends Object
    implements Iterable<T>
    Bulk items, with pre-saved JSON.

    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.

    Since:
    0.4
    Version:
    $Id: a092cd0bcf716ebef386f1782b3b75e12b173730 $
    Author:
    Yegor Bugayenko (yegor256@gmail.com)
    See Also:
    Pagination
    • Constructor Detail

      • Bulk

        public Bulk​(Iterable<T> items)
        Public ctor.
        Parameters:
        items - Items original
        Suppressed Checkstyle violations:
        AnonInnerLength (50 lines)