{"action":"created","comment":{"url":"https://api.github.com/repos/Azure/autorest/pulls/comments/56561155","id":56561155,"diff_hunk":"@@ -0,0 +1,277 @@\n+/**\n+ *\n+ * Copyright (c) Microsoft Corporation. All rights reserved.\n+ * Licensed under the MIT License. See License.txt in the project root for license information.\n+ *\n+ */\n+\n+package com.microsoft.azure;\n+\n+import java.io.IOException;\n+import java.util.Collection;\n+import java.util.Iterator;\n+import java.util.List;\n+import java.util.ListIterator;\n+import java.util.NoSuchElementException;\n+\n+import javax.xml.bind.DataBindingException;\n+import javax.xml.ws.WebServiceException;\n+\n+/**\n+ * Defines a list response from a paging operation. The pages are\n+ * lazy initialized when an instance of this class is iterated.\n+ *\n+ * @param <E> the element type.\n+ */\n+public abstract class PagedList<E> implements List<E> {\n+    /** The actual items in the list. */\n+    private List<E> items;\n+    /** Stores the link to get the next page of items. */\n+    private String nextPageLink;\n+\n+    /**\n+     * Creates an instance of PagedList from a {@link Page} response.\n+     *\n+     * @param page the {@link Page} object.\n+     */\n+    public PagedList(Page<E> page) {\n+        items = page.getItems();\n+        nextPageLink = page.getNextPageLink();\n+    }\n+\n+    /**\n+     * Override this method to load the next page of items from a next page link.\n+     *\n+     * @param nextPageLink the link to get the next page of items.\n+     * @return the {@link Page} object storing a page of items and a link to the next page.\n+     * @throws CloudException thrown if an error is raised from Azure.\n+     * @throws IOException thrown if there's any failure in deserialization.\n+     */\n+    public abstract Page<E> loadPage(String nextPageLink) throws CloudException, IOException;\n+\n+    /**\n+     * Keep loading the next page from the next page link until all items are loaded.\n+     */\n+    public void loadAll() {\n+        while (nextPageLink != null) {\n+            try {\n+                Page<E> nextPage = loadPage(nextPageLink);\n+                nextPageLink = nextPage.getNextPageLink();\n+                addAll(nextPage.getItems());\n+            } catch (CloudException e) {","path":"ClientRuntimes/Java/azure-client-runtime/src/main/java/com/microsoft/azure/PagedList.java","position":61,"original_position":61,"commit_id":"b43985272a7688a74bc9244fb7056b0d678735b7","original_commit_id":"b43985272a7688a74bc9244fb7056b0d678735b7","user":{"login":"jianghaolu","id":2320445,"avatar_url":"https://avatars.githubusercontent.com/u/2320445?v=3","gravatar_id":"","url":"https://api.github.com/users/jianghaolu","html_url":"https://github.com/jianghaolu","followers_url":"https://api.github.com/users/jianghaolu/followers","following_url":"https://api.github.com/users/jianghaolu/following{/other_user}","gists_url":"https://api.github.com/users/jianghaolu/gists{/gist_id}","starred_url":"https://api.github.com/users/jianghaolu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jianghaolu/subscriptions","organizations_url":"https://api.github.com/users/jianghaolu/orgs","repos_url":"https://api.github.com/users/jianghaolu/repos","events_url":"https://api.github.com/users/jianghaolu/events{/privacy}","received_events_url":"https://api.github.com/users/jianghaolu/received_events","type":"User","site_admin":false},"body":"A [RuntimeException](https://docs.oracle.com/javase/7/docs/api/java/lang/RuntimeException.html) is required here so I have to wrap them up.","created_at":"2016-03-17T19:09:19Z","updated_at":"2016-03-17T19:09:19Z","html_url":"https://github.com/Azure/autorest/pull/851#discussion_r56561155","pull_request_url":"https://api.github.com/repos/Azure/autorest/pulls/851","_links":{"self":{"href":"https://api.github.com/repos/Azure/autorest/pulls/comments/56561155"},"html":{"href":"https://github.com/Azure/autorest/pull/851#discussion_r56561155"},"pull_request":{"href":"https://api.github.com/repos/Azure/autorest/pulls/851"}}},"pull_request":{"url":"https://api.github.com/repos/Azure/autorest/pulls/851","id":63144453,"html_url":"https://github.com/Azure/autorest/pull/851","diff_url":"https://github.com/Azure/autorest/pull/851.diff","patch_url":"https://github.com/Azure/autorest/pull/851.patch","issue_url":"https://api.github.com/repos/Azure/autorest/issues/851","number":851,"state":"open","locked":false,"title":"Lazy initialized paging results","user":{"login":"jianghaolu","id":2320445,"avatar_url":"https://avatars.githubusercontent.com/u/2320445?v=3","gravatar_id":"","url":"https://api.github.com/users/jianghaolu","html_url":"https://github.com/jianghaolu","followers_url":"https://api.github.com/users/jianghaolu/followers","following_url":"https://api.github.com/users/jianghaolu/following{/other_user}","gists_url":"https://api.github.com/users/jianghaolu/gists{/gist_id}","starred_url":"https://api.github.com/users/jianghaolu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jianghaolu/subscriptions","organizations_url":"https://api.github.com/users/jianghaolu/orgs","repos_url":"https://api.github.com/users/jianghaolu/repos","events_url":"https://api.github.com/users/jianghaolu/events{/privacy}","received_events_url":"https://api.github.com/users/jianghaolu/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-03-16T22:11:33Z","updated_at":"2016-03-17T19:09:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a48711162e5baa7b06ef60fae0015dd51b1c350f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Azure/autorest/pulls/851/commits","review_comments_url":"https://api.github.com/repos/Azure/autorest/pulls/851/comments","review_comment_url":"https://api.github.com/repos/Azure/autorest/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Azure/autorest/issues/851/comments","statuses_url":"https://api.github.com/repos/Azure/autorest/statuses/b43985272a7688a74bc9244fb7056b0d678735b7","head":{"label":"jianghaolu:lazy","ref":"lazy","sha":"b43985272a7688a74bc9244fb7056b0d678735b7","user":{"login":"jianghaolu","id":2320445,"avatar_url":"https://avatars.githubusercontent.com/u/2320445?v=3","gravatar_id":"","url":"https://api.github.com/users/jianghaolu","html_url":"https://github.com/jianghaolu","followers_url":"https://api.github.com/users/jianghaolu/followers","following_url":"https://api.github.com/users/jianghaolu/following{/other_user}","gists_url":"https://api.github.com/users/jianghaolu/gists{/gist_id}","starred_url":"https://api.github.com/users/jianghaolu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jianghaolu/subscriptions","organizations_url":"https://api.github.com/users/jianghaolu/orgs","repos_url":"https://api.github.com/users/jianghaolu/repos","events_url":"https://api.github.com/users/jianghaolu/events{/privacy}","received_events_url":"https://api.github.com/users/jianghaolu/received_events","type":"User","site_admin":false},"repo":{"id":33385201,"name":"AutoRest","full_name":"jianghaolu/AutoRest","owner":{"login":"jianghaolu","id":2320445,"avatar_url":"https://avatars.githubusercontent.com/u/2320445?v=3","gravatar_id":"","url":"https://api.github.com/users/jianghaolu","html_url":"https://github.com/jianghaolu","followers_url":"https://api.github.com/users/jianghaolu/followers","following_url":"https://api.github.com/users/jianghaolu/following{/other_user}","gists_url":"https://api.github.com/users/jianghaolu/gists{/gist_id}","starred_url":"https://api.github.com/users/jianghaolu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jianghaolu/subscriptions","organizations_url":"https://api.github.com/users/jianghaolu/orgs","repos_url":"https://api.github.com/users/jianghaolu/repos","events_url":"https://api.github.com/users/jianghaolu/events{/privacy}","received_events_url":"https://api.github.com/users/jianghaolu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jianghaolu/AutoRest","description":"","fork":true,"url":"https://api.github.com/repos/jianghaolu/AutoRest","forks_url":"https://api.github.com/repos/jianghaolu/AutoRest/forks","keys_url":"https://api.github.com/repos/jianghaolu/AutoRest/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jianghaolu/AutoRest/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jianghaolu/AutoRest/teams","hooks_url":"https://api.github.com/repos/jianghaolu/AutoRest/hooks","issue_events_url":"https://api.github.com/repos/jianghaolu/AutoRest/issues/events{/number}","events_url":"https://api.github.com/repos/jianghaolu/AutoRest/events","assignees_url":"https://api.github.com/repos/jianghaolu/AutoRest/assignees{/user}","branches_url":"https://api.github.com/repos/jianghaolu/AutoRest/branches{/branch}","tags_url":"https://api.github.com/repos/jianghaolu/AutoRest/tags","blobs_url":"https://api.github.com/repos/jianghaolu/AutoRest/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jianghaolu/AutoRest/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jianghaolu/AutoRest/git/refs{/sha}","trees_url":"https://api.github.com/repos/jianghaolu/AutoRest/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jianghaolu/AutoRest/statuses/{sha}","languages_url":"https://api.github.com/repos/jianghaolu/AutoRest/languages","stargazers_url":"https://api.github.com/repos/jianghaolu/AutoRest/stargazers","contributors_url":"https://api.github.com/repos/jianghaolu/AutoRest/contributors","subscribers_url":"https://api.github.com/repos/jianghaolu/AutoRest/subscribers","subscription_url":"https://api.github.com/repos/jianghaolu/AutoRest/subscription","commits_url":"https://api.github.com/repos/jianghaolu/AutoRest/commits{/sha}","git_commits_url":"https://api.github.com/repos/jianghaolu/AutoRest/git/commits{/sha}","comments_url":"https://api.github.com/repos/jianghaolu/AutoRest/comments{/number}","issue_comment_url":"https://api.github.com/repos/jianghaolu/AutoRest/issues/comments{/number}","contents_url":"https://api.github.com/repos/jianghaolu/AutoRest/contents/{+path}","compare_url":"https://api.github.com/repos/jianghaolu/AutoRest/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jianghaolu/AutoRest/merges","archive_url":"https://api.github.com/repos/jianghaolu/AutoRest/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jianghaolu/AutoRest/downloads","issues_url":"https://api.github.com/repos/jianghaolu/AutoRest/issues{/number}","pulls_url":"https://api.github.com/repos/jianghaolu/AutoRest/pulls{/number}","milestones_url":"https://api.github.com/repos/jianghaolu/AutoRest/milestones{/number}","notifications_url":"https://api.github.com/repos/jianghaolu/AutoRest/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jianghaolu/AutoRest/labels{/name}","releases_url":"https://api.github.com/repos/jianghaolu/AutoRest/releases{/id}","deployments_url":"https://api.github.com/repos/jianghaolu/AutoRest/deployments","created_at":"2015-04-03T22:12:53Z","updated_at":"2016-01-14T21:29:46Z","pushed_at":"2016-03-17T18:30:36Z","git_url":"git://github.com/jianghaolu/AutoRest.git","ssh_url":"git@github.com:jianghaolu/AutoRest.git","clone_url":"https://github.com/jianghaolu/AutoRest.git","svn_url":"https://github.com/jianghaolu/AutoRest","homepage":null,"size":41382,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Azure:master","ref":"master","sha":"5fa2ff1f1a00dbbf46da34965b3ac770c4b0b8d8","user":{"login":"Azure","id":6844498,"avatar_url":"https://avatars.githubusercontent.com/u/6844498?v=3","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"repo":{"id":31089461,"name":"autorest","full_name":"Azure/autorest","owner":{"login":"Azure","id":6844498,"avatar_url":"https://avatars.githubusercontent.com/u/6844498?v=3","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Azure/autorest","description":"","fork":false,"url":"https://api.github.com/repos/Azure/autorest","forks_url":"https://api.github.com/repos/Azure/autorest/forks","keys_url":"https://api.github.com/repos/Azure/autorest/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Azure/autorest/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Azure/autorest/teams","hooks_url":"https://api.github.com/repos/Azure/autorest/hooks","issue_events_url":"https://api.github.com/repos/Azure/autorest/issues/events{/number}","events_url":"https://api.github.com/repos/Azure/autorest/events","assignees_url":"https://api.github.com/repos/Azure/autorest/assignees{/user}","branches_url":"https://api.github.com/repos/Azure/autorest/branches{/branch}","tags_url":"https://api.github.com/repos/Azure/autorest/tags","blobs_url":"https://api.github.com/repos/Azure/autorest/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Azure/autorest/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Azure/autorest/git/refs{/sha}","trees_url":"https://api.github.com/repos/Azure/autorest/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Azure/autorest/statuses/{sha}","languages_url":"https://api.github.com/repos/Azure/autorest/languages","stargazers_url":"https://api.github.com/repos/Azure/autorest/stargazers","contributors_url":"https://api.github.com/repos/Azure/autorest/contributors","subscribers_url":"https://api.github.com/repos/Azure/autorest/subscribers","subscription_url":"https://api.github.com/repos/Azure/autorest/subscription","commits_url":"https://api.github.com/repos/Azure/autorest/commits{/sha}","git_commits_url":"https://api.github.com/repos/Azure/autorest/git/commits{/sha}","comments_url":"https://api.github.com/repos/Azure/autorest/comments{/number}","issue_comment_url":"https://api.github.com/repos/Azure/autorest/issues/comments{/number}","contents_url":"https://api.github.com/repos/Azure/autorest/contents/{+path}","compare_url":"https://api.github.com/repos/Azure/autorest/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Azure/autorest/merges","archive_url":"https://api.github.com/repos/Azure/autorest/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Azure/autorest/downloads","issues_url":"https://api.github.com/repos/Azure/autorest/issues{/number}","pulls_url":"https://api.github.com/repos/Azure/autorest/pulls{/number}","milestones_url":"https://api.github.com/repos/Azure/autorest/milestones{/number}","notifications_url":"https://api.github.com/repos/Azure/autorest/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Azure/autorest/labels{/name}","releases_url":"https://api.github.com/repos/Azure/autorest/releases{/id}","deployments_url":"https://api.github.com/repos/Azure/autorest/deployments","created_at":"2015-02-20T23:02:54Z","updated_at":"2016-03-10T00:51:13Z","pushed_at":"2016-03-17T18:30:37Z","git_url":"git://github.com/Azure/autorest.git","ssh_url":"git@github.com:Azure/autorest.git","clone_url":"https://github.com/Azure/autorest.git","svn_url":"https://github.com/Azure/autorest","homepage":null,"size":43089,"stargazers_count":325,"watchers_count":325,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":96,"mirror_url":null,"open_issues_count":66,"forks":96,"open_issues":66,"watchers":325,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Azure/autorest/pulls/851"},"html":{"href":"https://github.com/Azure/autorest/pull/851"},"issue":{"href":"https://api.github.com/repos/Azure/autorest/issues/851"},"comments":{"href":"https://api.github.com/repos/Azure/autorest/issues/851/comments"},"review_comments":{"href":"https://api.github.com/repos/Azure/autorest/pulls/851/comments"},"review_comment":{"href":"https://api.github.com/repos/Azure/autorest/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Azure/autorest/pulls/851/commits"},"statuses":{"href":"https://api.github.com/repos/Azure/autorest/statuses/b43985272a7688a74bc9244fb7056b0d678735b7"}}}}