Remove fetchArray method

This commit is contained in:
Liam Newman
2020-02-24 08:26:04 -08:00
parent 9e8bbfd175
commit d77b99d3d4
6 changed files with 54 additions and 44 deletions

View File

@@ -69,7 +69,10 @@ public class GHMyself extends GHUser {
* the io exception
*/
public List<GHEmail> getEmails2() throws IOException {
GHEmail[] addresses = root.createRequest().withUrlPath("/user/emails").fetchArray(GHEmail[].class);
GHEmail[] addresses = root.createRequest()
.withUrlPath("/user/emails")
.toIterable(GHEmail[].class, null)
.toArray();
return Collections.unmodifiableList(Arrays.asList(addresses));
}
@@ -84,8 +87,8 @@ public class GHMyself extends GHUser {
* the io exception
*/
public List<GHKey> getPublicKeys() throws IOException {
return Collections.unmodifiableList(
Arrays.asList(root.createRequest().withUrlPath("/user/keys").fetchArray(GHKey[].class)));
return Collections.unmodifiableList(Arrays
.asList(root.createRequest().withUrlPath("/user/keys").toIterable(GHKey[].class, null).toArray()));
}
/**
@@ -99,8 +102,10 @@ public class GHMyself extends GHUser {
* the io exception
*/
public List<GHVerifiedKey> getPublicVerifiedKeys() throws IOException {
return Collections.unmodifiableList(Arrays.asList(
root.createRequest().withUrlPath("/users/" + getLogin() + "/keys").fetchArray(GHVerifiedKey[].class)));
return Collections.unmodifiableList(Arrays.asList(root.createRequest()
.withUrlPath("/users/" + getLogin() + "/keys")
.toIterable(GHVerifiedKey[].class, null)
.toArray()));
}
/**
@@ -113,7 +118,10 @@ public class GHMyself extends GHUser {
public GHPersonSet<GHOrganization> getAllOrganizations() throws IOException {
GHPersonSet<GHOrganization> orgs = new GHPersonSet<GHOrganization>();
Set<String> names = new HashSet<String>();
for (GHOrganization o : root.createRequest().withUrlPath("/user/orgs").fetchArray(GHOrganization[].class)) {
for (GHOrganization o : root.createRequest()
.withUrlPath("/user/orgs")
.toIterable(GHOrganization[].class, null)
.toArray()) {
if (names.add(o.getLogin())) // in case of rumoured duplicates in the data
orgs.add(root.getOrganization(o.getLogin()));
}