3939import java .net .URL ;
4040import java .util .AbstractSet ;
4141import java .util .ArrayList ;
42- import java .util .Arrays ;
4342import java .util .Collection ;
4443import java .util .Collections ;
4544import java .util .Date ;
@@ -358,7 +357,7 @@ public GHIssueBuilder createIssue(String title) {
358357 * the io exception
359358 */
360359 public List <GHIssue > getIssues (GHIssueState state ) throws IOException {
361- return listIssues (state ).asList ();
360+ return listIssues (state ).toList ();
362361 }
363362
364363 /**
@@ -376,8 +375,9 @@ public List<GHIssue> getIssues(GHIssueState state, GHMilestone milestone) throws
376375 Requester requester = root .createRequest ()
377376 .with ("state" , state )
378377 .with ("milestone" , milestone == null ? "none" : "" + milestone .getNumber ());
379- return Arrays
380- .asList (GHIssue .wrap (requester .withUrlPath (getApiTailUrl ("issues" )).fetchArray (GHIssue [].class ), this ));
378+ return requester .withUrlPath (getApiTailUrl ("issues" ))
379+ .toIterable (GHIssue [].class , item -> item .wrap (this ))
380+ .toList ();
381381 }
382382
383383 /**
@@ -436,7 +436,7 @@ public GHRef createRef(String name, String sha) throws IOException {
436436 * @deprecated use {@link #listReleases()}
437437 */
438438 public List <GHRelease > getReleases () throws IOException {
439- return listReleases ().asList ();
439+ return listReleases ().toList ();
440440 }
441441
442442 /**
@@ -734,7 +734,7 @@ public int getSize() {
734734 */
735735 @ WithBridgeMethods (Set .class )
736736 public GHPersonSet <GHUser > getCollaborators () throws IOException {
737- return new GHPersonSet <GHUser >(listCollaborators ().asList ());
737+ return new GHPersonSet <GHUser >(listCollaborators ().toList ());
738738 }
739739
740740 /**
@@ -784,11 +784,14 @@ public boolean hasAssignee(GHUser u) throws IOException {
784784 * the io exception
785785 */
786786 public Set <String > getCollaboratorNames () throws IOException {
787- Set <String > r = new HashSet <String >();
788- for (GHUser u : GHUser .wrap (
789- root .createRequest ().withUrlPath (getApiTailUrl ("collaborators" )).fetchArray (GHUser [].class ),
790- root ))
787+ Set <String > r = new HashSet <>();
788+ // no initializer - we just want to the logins
789+ PagedIterable <GHUser > users = root .createRequest ()
790+ .withUrlPath (getApiTailUrl ("collaborators" ))
791+ .toIterable (GHUser [].class , null );
792+ for (GHUser u : users .toArray ()) {
791793 r .add (u .login );
794+ }
792795 return r ;
793796 }
794797
@@ -830,9 +833,11 @@ public GHPermissionType getPermission(GHUser u) throws IOException {
830833 * the io exception
831834 */
832835 public Set <GHTeam > getTeams () throws IOException {
833- return Collections .unmodifiableSet (new HashSet <GHTeam >(Arrays .asList (
834- GHTeam .wrapUp (root .createRequest ().withUrlPath (getApiTailUrl ("teams" )).fetchArray (GHTeam [].class ),
835- root .getOrganization (getOwnerName ())))));
836+ GHOrganization org = root .getOrganization (getOwnerName ());
837+ return root .createRequest ()
838+ .withUrlPath (getApiTailUrl ("teams" ))
839+ .toIterable (GHTeam [].class , item -> item .wrapUp (org ))
840+ .toSet ();
836841 }
837842
838843 /**
@@ -1238,7 +1243,7 @@ public GHPullRequest getPullRequest(int i) throws IOException {
12381243 * @see #listPullRequests(GHIssueState) #listPullRequests(GHIssueState)
12391244 */
12401245 public List <GHPullRequest > getPullRequests (GHIssueState state ) throws IOException {
1241- return queryPullRequests ().state (state ).list ().asList ();
1246+ return queryPullRequests ().state (state ).list ().toList ();
12421247 }
12431248
12441249 /**
@@ -1449,9 +1454,7 @@ public GHCompare getCompare(GHBranch id1, GHBranch id2) throws IOException {
14491454 * on failure communicating with GitHub
14501455 */
14511456 public GHRef [] getRefs () throws IOException {
1452- return GHRef .wrap (root .createRequest ()
1453- .withUrlPath (String .format ("/repos/%s/%s/git/refs" , getOwnerName (), name ))
1454- .fetchArray (GHRef [].class ), root );
1457+ return listRefs ().toArray ();
14551458 }
14561459
14571460 /**
@@ -1476,9 +1479,7 @@ public PagedIterable<GHRef> listRefs() throws IOException {
14761479 * on failure communicating with GitHub, potentially due to an invalid ref type being requested
14771480 */
14781481 public GHRef [] getRefs (String refType ) throws IOException {
1479- return GHRef .wrap (root .createRequest ()
1480- .withUrlPath (String .format ("/repos/%s/%s/git/refs/%s" , getOwnerName (), name , refType ))
1481- .fetchArray (GHRef [].class ), root );
1482+ return listRefs (refType ).toArray ();
14821483 }
14831484
14841485 /**
@@ -1736,7 +1737,7 @@ public PagedIterable<GHCommitStatus> listCommitStatuses(final String sha1) throw
17361737 * the io exception
17371738 */
17381739 public GHCommitStatus getLastCommitStatus (String sha1 ) throws IOException {
1739- List <GHCommitStatus > v = listCommitStatuses (sha1 ).asList ();
1740+ List <GHCommitStatus > v = listCommitStatuses (sha1 ).toList ();
17401741 return v .isEmpty () ? null : v .get (0 );
17411742 }
17421743
@@ -2071,8 +2072,10 @@ GHRepository wrap(GitHub root) {
20712072 */
20722073 public Map <String , GHBranch > getBranches () throws IOException {
20732074 Map <String , GHBranch > r = new TreeMap <String , GHBranch >();
2074- for (GHBranch p : root .createRequest ().withUrlPath (getApiTailUrl ("branches" )).fetchArray (GHBranch [].class )) {
2075- p .wrap (this );
2075+ for (GHBranch p : root .createRequest ()
2076+ .withUrlPath (getApiTailUrl ("branches" ))
2077+ .toIterable (GHBranch [].class , item -> item .wrap (this ))
2078+ .toArray ()) {
20762079 r .put (p .getName (), p );
20772080 }
20782081 return r ;
@@ -2203,11 +2206,10 @@ public List<GHContent> getDirectoryContent(String path, String ref) throws IOExc
22032206 }
22042207 String target = getApiTailUrl ("contents/" + path );
22052208
2206- GHContent [] files = requester .with ("ref" , ref ).withUrlPath (target ).fetchArray (GHContent [].class );
2207-
2208- GHContent .wrap (files , this );
2209-
2210- return Arrays .asList (files );
2209+ return requester .with ("ref" , ref )
2210+ .withUrlPath (target )
2211+ .toIterable (GHContent [].class , item -> item .wrap (this ))
2212+ .toList ();
22112213 }
22122214
22132215 /**
@@ -2361,11 +2363,10 @@ public GHDeployKey addDeployKey(String title, String key) throws IOException {
23612363 * the io exception
23622364 */
23632365 public List <GHDeployKey > getDeployKeys () throws IOException {
2364- List <GHDeployKey > list = new ArrayList <GHDeployKey >(
2365- Arrays .asList (root .createRequest ().withUrlPath (getApiTailUrl ("keys" )).fetchArray (GHDeployKey [].class )));
2366- for (GHDeployKey h : list )
2367- h .wrap (this );
2368- return list ;
2366+ return root .createRequest ()
2367+ .withUrlPath (getApiTailUrl ("keys" ))
2368+ .toIterable (GHDeployKey [].class , item -> item .wrap (this ))
2369+ .toList ();
23692370 }
23702371
23712372 /**
0 commit comments