Skip to content

Commit

Permalink
Further clean up of refactored classes
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwiseman committed Feb 12, 2020
1 parent 5939874 commit eb4ce6d
Show file tree
Hide file tree
Showing 26 changed files with 1,398 additions and 356 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spotbugs-maven-plugin.version>3.1.12.2</spotbugs-maven-plugin.version>
<spotbugs.version>3.1.12</spotbugs.version>
<spotbugs.version>4.0.0-RC3</spotbugs.version>
<spotbugs-maven-plugin.failOnError>true</spotbugs-maven-plugin.failOnError>
<hamcrest.version>2.2</hamcrest.version>
<okhttp3.version>4.3.1</okhttp3.version>
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/kohsuke/github/GHPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ public PagedIterable<GHRepository> listRepositories(final int pageSize) {
public synchronized Iterable<List<GHRepository>> iterateRepositories(final int pageSize) {
return new Iterable<List<GHRepository>>() {
public Iterator<List<GHRepository>> iterator() {
final Iterator<GHRepository[]> pager = root.createRequest()
.withUrlPath("users", login, "repos")
.fetchIterator(GHRepository[].class, pageSize);
final Iterator<GHRepository[]> pager = GitHubPageIterator.create(root.getClient(),
GHRepository[].class,
root.createRequest().withUrlPath("users", login, "repos").withPageSize(pageSize));

return new Iterator<List<GHRepository>>() {
public boolean hasNext() {
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/kohsuke/github/GHSearchBuilder.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.kohsuke.github;

import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -43,9 +44,11 @@ public GHQueryBuilder<T> q(String term) {
@Override
public PagedSearchIterable<T> list() {
return new PagedSearchIterable<T>(root) {
@NotNull
public PagedIterator<T> _iterator(int pageSize) {
req.set("q", StringUtils.join(terms, " "));
return new PagedIterator<T>(adapt(req.withUrlPath(getApiUrl()).fetchIterator(receiverType, pageSize))) {
return new PagedIterator<T>(adapt(GitHubPageIterator
.create(req.client, receiverType, req.withUrlPath(getApiUrl()).withPageSize(pageSize)))) {
protected void wrapUp(T[] page) {
// SearchResult.getItems() should do it
}
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/org/kohsuke/github/GitHub.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
public class GitHub {

@Nonnull
/* private */ final GitHubClient client;
private final GitHubClient client;

@CheckForNull
private GHMyself myself;
Expand Down Expand Up @@ -405,7 +405,7 @@ GHMyself getMyself() throws IOException {
client.requireCredential();
synchronized (this) {
if (this.myself == null) {
GHMyself u = client.createRequest().withUrlPath("/user").fetch(GHMyself.class);
GHMyself u = createRequest().withUrlPath("/user").fetch(GHMyself.class);
setMyself(u);
}
return myself;
Expand Down Expand Up @@ -1175,8 +1175,14 @@ public Reader renderMarkdown(String text) throws IOException {
"UTF-8");
}

@Nonnull
GitHubClient getClient() {
return client;
}

@Nonnull
Requester createRequest() {
return client.createRequest();
return new Requester(client);
}

GHUser intern(GHUser user) throws IOException {
Expand Down
Loading

0 comments on commit eb4ce6d

Please sign in to comment.