diff --git a/src/main/java/org/kohsuke/github/GHOrganization.java b/src/main/java/org/kohsuke/github/GHOrganization.java index ec899c0538..5d0eb7cd63 100644 --- a/src/main/java/org/kohsuke/github/GHOrganization.java +++ b/src/main/java/org/kohsuke/github/GHOrganization.java @@ -80,24 +80,14 @@ public void publicize(GHUser u) throws IOException { /** * All the members of this organization. */ - public List getMembers() throws IOException { - return new AbstractList() { - // these are shallow objects with only some limited values filled out - // TODO: it's better to allow objects to fill themselves in later when missing values are requested - final GHUser[] shallow = root.retrieve().to("/orgs/" + login + "/members", GHUser[].class); - - @Override - public GHUser get(int index) { - try { - return root.getUser(shallow[index].getLogin()); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - @Override - public int size() { - return shallow.length; + public PagedIterable getMembers() throws IOException { + return new PagedIterable() { + public PagedIterator iterator() { + return new PagedIterator(root.retrieve().asIterator(String.format("/orgs/%s/members", login), GHUser[].class)) { + @Override + protected void wrapUp(GHUser[] page) { + } + }; } }; }