{"action":"created","comment":{"url":"https://api.github.com/repos/googleapis/gax-java/pulls/comments/77697549","id":77697549,"diff_hunk":"@@ -0,0 +1,166 @@\n+/*\n+ * Copyright 2016, Google Inc.\n+ * All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or without\n+ * modification, are permitted provided that the following conditions are\n+ * met:\n+ *\n+ *     * Redistributions of source code must retain the above copyright\n+ * notice, this list of conditions and the following disclaimer.\n+ *     * Redistributions in binary form must reproduce the above\n+ * copyright notice, this list of conditions and the following disclaimer\n+ * in the documentation and/or other materials provided with the\n+ * distribution.\n+ *     * Neither the name of Google Inc. nor the names of its\n+ * contributors may be used to endorse or promote products derived from\n+ * this software without specific prior written permission.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+package com.google.api.gax.grpc;\n+\n+import com.google.api.gax.core.Page;\n+import com.google.api.gax.protobuf.ValidationException;\n+import com.google.common.base.Throwables;\n+import com.google.common.collect.AbstractIterator;\n+import com.google.common.collect.Iterators;\n+import com.google.common.util.concurrent.Futures;\n+import com.google.common.util.concurrent.UncheckedExecutionException;\n+\n+import io.grpc.StatusRuntimeException;\n+\n+import java.util.Iterator;\n+import java.util.concurrent.Future;\n+\n+class PageImpl<RequestT, ResponseT, ResourceT> implements Page<RequestT, ResponseT, ResourceT> {\n+\n+  private final FutureCallable<RequestT, ResponseT> callable;\n+  private final PageStreamingDescriptor<RequestT, ResponseT, ResourceT> pageDescriptor;\n+  private final CallContext<RequestT> context;\n+  private ResponseT response;\n+\n+  /** */\n+  public PageImpl(\n+      FutureCallable<RequestT, ResponseT> callable,\n+      PageStreamingDescriptor<RequestT, ResponseT, ResourceT> pageDescriptor,\n+      CallContext<RequestT> context) {\n+    this.callable = callable;\n+    this.pageDescriptor = pageDescriptor;\n+    this.context = context;\n+\n+    // Make the API call eagerly\n+    this.response = getUnchecked(callable.futureCall(context));\n+  }\n+\n+  @Override\n+  public Iterator<ResourceT> iterator() {\n+    return pageDescriptor.extractResources(response).iterator();\n+  }\n+\n+  @Override\n+  public boolean hasNextPage() {\n+    return !getNextPageToken().equals(pageDescriptor.emptyToken());\n+  }\n+\n+  @Override\n+  public Object getNextPageToken() {\n+    return pageDescriptor.extractNextToken(response);\n+  }\n+\n+  @Override\n+  public Page<RequestT, ResponseT, ResourceT> getNextPage() {\n+    if (!hasNextPage()) {\n+      throw new ValidationException(\n+          \"Could not complete getNextPage operation: there are no more pages to retrieve.\");","path":"src/main/java/com/google/api/gax/grpc/PageImpl.java","position":86,"original_position":86,"commit_id":"207d798d437d18ec3d70e206f3e55f4aef7581c0","original_commit_id":"207d798d437d18ec3d70e206f3e55f4aef7581c0","user":{"login":"garrettjonesgoogle","id":13341017,"avatar_url":"https://avatars.githubusercontent.com/u/13341017?v=3","gravatar_id":"","url":"https://api.github.com/users/garrettjonesgoogle","html_url":"https://github.com/garrettjonesgoogle","followers_url":"https://api.github.com/users/garrettjonesgoogle/followers","following_url":"https://api.github.com/users/garrettjonesgoogle/following{/other_user}","gists_url":"https://api.github.com/users/garrettjonesgoogle/gists{/gist_id}","starred_url":"https://api.github.com/users/garrettjonesgoogle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garrettjonesgoogle/subscriptions","organizations_url":"https://api.github.com/users/garrettjonesgoogle/orgs","repos_url":"https://api.github.com/users/garrettjonesgoogle/repos","events_url":"https://api.github.com/users/garrettjonesgoogle/events{/privacy}","received_events_url":"https://api.github.com/users/garrettjonesgoogle/received_events","type":"User","site_admin":false},"body":"I think we should use NoSuchElementException, like Iterator uses for next():\r\n\r\nhttps://docs.oracle.com/javase/7/docs/api/java/util/Iterator.html\r\n\r\nMaybe we should also consider a naming scheme like \"nextPage()\". (lower priority)","created_at":"2016-09-06T18:59:02Z","updated_at":"2016-09-06T18:59:02Z","html_url":"https://github.com/googleapis/gax-java/pull/105#discussion_r77697549","pull_request_url":"https://api.github.com/repos/googleapis/gax-java/pulls/105","_links":{"self":{"href":"https://api.github.com/repos/googleapis/gax-java/pulls/comments/77697549"},"html":{"href":"https://github.com/googleapis/gax-java/pull/105#discussion_r77697549"},"pull_request":{"href":"https://api.github.com/repos/googleapis/gax-java/pulls/105"}}},"pull_request":{"url":"https://api.github.com/repos/googleapis/gax-java/pulls/105","id":82639078,"html_url":"https://github.com/googleapis/gax-java/pull/105","diff_url":"https://github.com/googleapis/gax-java/pull/105.diff","patch_url":"https://github.com/googleapis/gax-java/pull/105.patch","issue_url":"https://api.github.com/repos/googleapis/gax-java/issues/105","number":105,"state":"open","locked":false,"title":"Convert PageAccessor to PagedListResponse","user":{"login":"michaelbausor","id":14846209,"avatar_url":"https://avatars.githubusercontent.com/u/14846209?v=3","gravatar_id":"","url":"https://api.github.com/users/michaelbausor","html_url":"https://github.com/michaelbausor","followers_url":"https://api.github.com/users/michaelbausor/followers","following_url":"https://api.github.com/users/michaelbausor/following{/other_user}","gists_url":"https://api.github.com/users/michaelbausor/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelbausor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelbausor/subscriptions","organizations_url":"https://api.github.com/users/michaelbausor/orgs","repos_url":"https://api.github.com/users/michaelbausor/repos","events_url":"https://api.github.com/users/michaelbausor/events{/privacy}","received_events_url":"https://api.github.com/users/michaelbausor/received_events","type":"User","site_admin":false},"body":"Replaces PageAccessor with PagedListResponse\r\nAdds Page and FixedSizeCollection objects\r\nAdds unit tests","created_at":"2016-08-25T00:17:31Z","updated_at":"2016-09-06T18:59:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7a6302a7c0152f61e969fd7368c9af5710ce4316","assignee":{"login":"shinfan","id":1514780,"avatar_url":"https://avatars.githubusercontent.com/u/1514780?v=3","gravatar_id":"","url":"https://api.github.com/users/shinfan","html_url":"https://github.com/shinfan","followers_url":"https://api.github.com/users/shinfan/followers","following_url":"https://api.github.com/users/shinfan/following{/other_user}","gists_url":"https://api.github.com/users/shinfan/gists{/gist_id}","starred_url":"https://api.github.com/users/shinfan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shinfan/subscriptions","organizations_url":"https://api.github.com/users/shinfan/orgs","repos_url":"https://api.github.com/users/shinfan/repos","events_url":"https://api.github.com/users/shinfan/events{/privacy}","received_events_url":"https://api.github.com/users/shinfan/received_events","type":"User","site_admin":false},"assignees":[{"login":"shinfan","id":1514780,"avatar_url":"https://avatars.githubusercontent.com/u/1514780?v=3","gravatar_id":"","url":"https://api.github.com/users/shinfan","html_url":"https://github.com/shinfan","followers_url":"https://api.github.com/users/shinfan/followers","following_url":"https://api.github.com/users/shinfan/following{/other_user}","gists_url":"https://api.github.com/users/shinfan/gists{/gist_id}","starred_url":"https://api.github.com/users/shinfan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shinfan/subscriptions","organizations_url":"https://api.github.com/users/shinfan/orgs","repos_url":"https://api.github.com/users/shinfan/repos","events_url":"https://api.github.com/users/shinfan/events{/privacy}","received_events_url":"https://api.github.com/users/shinfan/received_events","type":"User","site_admin":false},{"login":"garrettjonesgoogle","id":13341017,"avatar_url":"https://avatars.githubusercontent.com/u/13341017?v=3","gravatar_id":"","url":"https://api.github.com/users/garrettjonesgoogle","html_url":"https://github.com/garrettjonesgoogle","followers_url":"https://api.github.com/users/garrettjonesgoogle/followers","following_url":"https://api.github.com/users/garrettjonesgoogle/following{/other_user}","gists_url":"https://api.github.com/users/garrettjonesgoogle/gists{/gist_id}","starred_url":"https://api.github.com/users/garrettjonesgoogle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garrettjonesgoogle/subscriptions","organizations_url":"https://api.github.com/users/garrettjonesgoogle/orgs","repos_url":"https://api.github.com/users/garrettjonesgoogle/repos","events_url":"https://api.github.com/users/garrettjonesgoogle/events{/privacy}","received_events_url":"https://api.github.com/users/garrettjonesgoogle/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/googleapis/gax-java/pulls/105/commits","review_comments_url":"https://api.github.com/repos/googleapis/gax-java/pulls/105/comments","review_comment_url":"https://api.github.com/repos/googleapis/gax-java/pulls/comments{/number}","comments_url":"https://api.github.com/repos/googleapis/gax-java/issues/105/comments","statuses_url":"https://api.github.com/repos/googleapis/gax-java/statuses/207d798d437d18ec3d70e206f3e55f4aef7581c0","head":{"label":"michaelbausor:page-streaming","ref":"page-streaming","sha":"207d798d437d18ec3d70e206f3e55f4aef7581c0","user":{"login":"michaelbausor","id":14846209,"avatar_url":"https://avatars.githubusercontent.com/u/14846209?v=3","gravatar_id":"","url":"https://api.github.com/users/michaelbausor","html_url":"https://github.com/michaelbausor","followers_url":"https://api.github.com/users/michaelbausor/followers","following_url":"https://api.github.com/users/michaelbausor/following{/other_user}","gists_url":"https://api.github.com/users/michaelbausor/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelbausor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelbausor/subscriptions","organizations_url":"https://api.github.com/users/michaelbausor/orgs","repos_url":"https://api.github.com/users/michaelbausor/repos","events_url":"https://api.github.com/users/michaelbausor/events{/privacy}","received_events_url":"https://api.github.com/users/michaelbausor/received_events","type":"User","site_admin":false},"repo":{"id":55105212,"name":"gax-java","full_name":"michaelbausor/gax-java","owner":{"login":"michaelbausor","id":14846209,"avatar_url":"https://avatars.githubusercontent.com/u/14846209?v=3","gravatar_id":"","url":"https://api.github.com/users/michaelbausor","html_url":"https://github.com/michaelbausor","followers_url":"https://api.github.com/users/michaelbausor/followers","following_url":"https://api.github.com/users/michaelbausor/following{/other_user}","gists_url":"https://api.github.com/users/michaelbausor/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelbausor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelbausor/subscriptions","organizations_url":"https://api.github.com/users/michaelbausor/orgs","repos_url":"https://api.github.com/users/michaelbausor/repos","events_url":"https://api.github.com/users/michaelbausor/events{/privacy}","received_events_url":"https://api.github.com/users/michaelbausor/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/michaelbausor/gax-java","description":"","fork":true,"url":"https://api.github.com/repos/michaelbausor/gax-java","forks_url":"https://api.github.com/repos/michaelbausor/gax-java/forks","keys_url":"https://api.github.com/repos/michaelbausor/gax-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/michaelbausor/gax-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/michaelbausor/gax-java/teams","hooks_url":"https://api.github.com/repos/michaelbausor/gax-java/hooks","issue_events_url":"https://api.github.com/repos/michaelbausor/gax-java/issues/events{/number}","events_url":"https://api.github.com/repos/michaelbausor/gax-java/events","assignees_url":"https://api.github.com/repos/michaelbausor/gax-java/assignees{/user}","branches_url":"https://api.github.com/repos/michaelbausor/gax-java/branches{/branch}","tags_url":"https://api.github.com/repos/michaelbausor/gax-java/tags","blobs_url":"https://api.github.com/repos/michaelbausor/gax-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/michaelbausor/gax-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/michaelbausor/gax-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/michaelbausor/gax-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/michaelbausor/gax-java/statuses/{sha}","languages_url":"https://api.github.com/repos/michaelbausor/gax-java/languages","stargazers_url":"https://api.github.com/repos/michaelbausor/gax-java/stargazers","contributors_url":"https://api.github.com/repos/michaelbausor/gax-java/contributors","subscribers_url":"https://api.github.com/repos/michaelbausor/gax-java/subscribers","subscription_url":"https://api.github.com/repos/michaelbausor/gax-java/subscription","commits_url":"https://api.github.com/repos/michaelbausor/gax-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/michaelbausor/gax-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/michaelbausor/gax-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/michaelbausor/gax-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/michaelbausor/gax-java/contents/{+path}","compare_url":"https://api.github.com/repos/michaelbausor/gax-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/michaelbausor/gax-java/merges","archive_url":"https://api.github.com/repos/michaelbausor/gax-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/michaelbausor/gax-java/downloads","issues_url":"https://api.github.com/repos/michaelbausor/gax-java/issues{/number}","pulls_url":"https://api.github.com/repos/michaelbausor/gax-java/pulls{/number}","milestones_url":"https://api.github.com/repos/michaelbausor/gax-java/milestones{/number}","notifications_url":"https://api.github.com/repos/michaelbausor/gax-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/michaelbausor/gax-java/labels{/name}","releases_url":"https://api.github.com/repos/michaelbausor/gax-java/releases{/id}","deployments_url":"https://api.github.com/repos/michaelbausor/gax-java/deployments","created_at":"2016-03-30T23:35:50Z","updated_at":"2016-05-02T21:37:22Z","pushed_at":"2016-08-29T16:49:16Z","git_url":"git://github.com/michaelbausor/gax-java.git","ssh_url":"git@github.com:michaelbausor/gax-java.git","clone_url":"https://github.com/michaelbausor/gax-java.git","svn_url":"https://github.com/michaelbausor/gax-java","homepage":null,"size":748,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"googleapis:master","ref":"master","sha":"a5e136e5449768be6909352c3aafaf1bc4176f4e","user":{"login":"googleapis","id":16785467,"avatar_url":"https://avatars.githubusercontent.com/u/16785467?v=3","gravatar_id":"","url":"https://api.github.com/users/googleapis","html_url":"https://github.com/googleapis","followers_url":"https://api.github.com/users/googleapis/followers","following_url":"https://api.github.com/users/googleapis/following{/other_user}","gists_url":"https://api.github.com/users/googleapis/gists{/gist_id}","starred_url":"https://api.github.com/users/googleapis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/googleapis/subscriptions","organizations_url":"https://api.github.com/users/googleapis/orgs","repos_url":"https://api.github.com/users/googleapis/repos","events_url":"https://api.github.com/users/googleapis/events{/privacy}","received_events_url":"https://api.github.com/users/googleapis/received_events","type":"Organization","site_admin":false},"repo":{"id":50872805,"name":"gax-java","full_name":"googleapis/gax-java","owner":{"login":"googleapis","id":16785467,"avatar_url":"https://avatars.githubusercontent.com/u/16785467?v=3","gravatar_id":"","url":"https://api.github.com/users/googleapis","html_url":"https://github.com/googleapis","followers_url":"https://api.github.com/users/googleapis/followers","following_url":"https://api.github.com/users/googleapis/following{/other_user}","gists_url":"https://api.github.com/users/googleapis/gists{/gist_id}","starred_url":"https://api.github.com/users/googleapis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/googleapis/subscriptions","organizations_url":"https://api.github.com/users/googleapis/orgs","repos_url":"https://api.github.com/users/googleapis/repos","events_url":"https://api.github.com/users/googleapis/events{/privacy}","received_events_url":"https://api.github.com/users/googleapis/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/googleapis/gax-java","description":"Google API Extensions for Java","fork":false,"url":"https://api.github.com/repos/googleapis/gax-java","forks_url":"https://api.github.com/repos/googleapis/gax-java/forks","keys_url":"https://api.github.com/repos/googleapis/gax-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/googleapis/gax-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/googleapis/gax-java/teams","hooks_url":"https://api.github.com/repos/googleapis/gax-java/hooks","issue_events_url":"https://api.github.com/repos/googleapis/gax-java/issues/events{/number}","events_url":"https://api.github.com/repos/googleapis/gax-java/events","assignees_url":"https://api.github.com/repos/googleapis/gax-java/assignees{/user}","branches_url":"https://api.github.com/repos/googleapis/gax-java/branches{/branch}","tags_url":"https://api.github.com/repos/googleapis/gax-java/tags","blobs_url":"https://api.github.com/repos/googleapis/gax-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/googleapis/gax-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/googleapis/gax-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/googleapis/gax-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/googleapis/gax-java/statuses/{sha}","languages_url":"https://api.github.com/repos/googleapis/gax-java/languages","stargazers_url":"https://api.github.com/repos/googleapis/gax-java/stargazers","contributors_url":"https://api.github.com/repos/googleapis/gax-java/contributors","subscribers_url":"https://api.github.com/repos/googleapis/gax-java/subscribers","subscription_url":"https://api.github.com/repos/googleapis/gax-java/subscription","commits_url":"https://api.github.com/repos/googleapis/gax-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/googleapis/gax-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/googleapis/gax-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/googleapis/gax-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/googleapis/gax-java/contents/{+path}","compare_url":"https://api.github.com/repos/googleapis/gax-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/googleapis/gax-java/merges","archive_url":"https://api.github.com/repos/googleapis/gax-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/googleapis/gax-java/downloads","issues_url":"https://api.github.com/repos/googleapis/gax-java/issues{/number}","pulls_url":"https://api.github.com/repos/googleapis/gax-java/pulls{/number}","milestones_url":"https://api.github.com/repos/googleapis/gax-java/milestones{/number}","notifications_url":"https://api.github.com/repos/googleapis/gax-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/googleapis/gax-java/labels{/name}","releases_url":"https://api.github.com/repos/googleapis/gax-java/releases{/id}","deployments_url":"https://api.github.com/repos/googleapis/gax-java/deployments","created_at":"2016-02-01T21:33:22Z","updated_at":"2016-05-02T19:57:26Z","pushed_at":"2016-09-06T18:48:03Z","git_url":"git://github.com/googleapis/gax-java.git","ssh_url":"git@github.com:googleapis/gax-java.git","clone_url":"https://github.com/googleapis/gax-java.git","svn_url":"https://github.com/googleapis/gax-java","homepage":"","size":942,"stargazers_count":8,"watchers_count":8,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":6,"mirror_url":null,"open_issues_count":6,"forks":6,"open_issues":6,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/googleapis/gax-java/pulls/105"},"html":{"href":"https://github.com/googleapis/gax-java/pull/105"},"issue":{"href":"https://api.github.com/repos/googleapis/gax-java/issues/105"},"comments":{"href":"https://api.github.com/repos/googleapis/gax-java/issues/105/comments"},"review_comments":{"href":"https://api.github.com/repos/googleapis/gax-java/pulls/105/comments"},"review_comment":{"href":"https://api.github.com/repos/googleapis/gax-java/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/googleapis/gax-java/pulls/105/commits"},"statuses":{"href":"https://api.github.com/repos/googleapis/gax-java/statuses/207d798d437d18ec3d70e206f3e55f4aef7581c0"}}}}
{"actor":{"display_login":"garrettjonesgoogle"}}