Refactor GitHubRepository using Lombok/delegation
Makes the hierarchy from GHRepository more explicit and just changes
the way it gets implemented, using the Lombok annotations for delegating
methods to inner composite objects.
Change-Id: Ib3d47b7d226cce4680c80b4978323cb0d148d8c9
diff --git a/github-plugin/pom.xml b/github-plugin/pom.xml
index 7f80227..f78b026 100644
--- a/github-plugin/pom.xml
+++ b/github-plugin/pom.xml
@@ -169,5 +169,11 @@
<version>1.2</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <version>1.14.0</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitHubRepository.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitHubRepository.java
index 0c111d7..1896c04 100644
--- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitHubRepository.java
+++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitHubRepository.java
@@ -14,14 +14,10 @@
package com.googlesource.gerrit.plugins.github.git;
import java.io.IOException;
-import java.net.URL;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.kohsuke.github.*;
+import lombok.experimental.Delegate;
+
+import org.kohsuke.github.GHRepository;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
@@ -40,6 +36,8 @@
private final String repository;
private final GitHubLogin ghLogin;
private final String cloneUrl;
+
+ @Delegate
private GHRepository ghRepository;
public String getCloneUrl() {
@@ -67,343 +65,4 @@
this.ghRepository =
ghLogin.hub.getRepository(organisation + "/" + repository);
}
-
- public String getDescription() {
- return ghRepository.getDescription();
- }
-
- public String getHomepage() {
- return ghRepository.getHomepage();
- }
-
- public String getUrl() {
- return ghRepository.getUrl();
- }
-
- public String getGitTransportUrl() {
- return ghRepository.getGitTransportUrl();
- }
-
- public String gitHttpTransportUrl() {
- return ghRepository.gitHttpTransportUrl();
- }
-
- public String getName() {
- return ghRepository.getName();
- }
-
- public boolean hasPullAccess() {
- return ghRepository.hasPullAccess();
- }
-
- public boolean hasPushAccess() {
- return ghRepository.hasPushAccess();
- }
-
- public boolean hasAdminAccess() {
- return ghRepository.hasAdminAccess();
- }
-
- public String getLanguage() {
- return ghRepository.getLanguage();
- }
-
- public GHUser getOwner() throws IOException {
- return ghRepository.getOwner();
- }
-
- public GHIssue getIssue(int id) throws IOException {
- return ghRepository.getIssue(id);
- }
-
- public GHIssueBuilder createIssue(String title) {
- return ghRepository.createIssue(title);
- }
-
- public List<GHIssue> getIssues(GHIssueState state) throws IOException {
- return ghRepository.getIssues(state);
- }
-
- public PagedIterable<GHIssue> listIssues(GHIssueState state) {
- return ghRepository.listIssues(state);
- }
-
- public GHReleaseBuilder createRelease(String tag) {
- return ghRepository.createRelease(tag);
- }
-
- public List<GHRelease> getReleases() throws IOException {
- return ghRepository.getReleases();
- }
-
- public boolean hasIssues() {
- return ghRepository.hasIssues();
- }
-
- public boolean hasWiki() {
- return ghRepository.hasWiki();
- }
-
- public boolean isFork() {
- return ghRepository.isFork();
- }
-
- public int getForks() {
- return ghRepository.getForks();
- }
-
- public boolean isPrivate() {
- return ghRepository.isPrivate();
- }
-
- public boolean hasDownloads() {
- return ghRepository.hasDownloads();
- }
-
- public int getWatchers() {
- return ghRepository.getWatchers();
- }
-
- public int getOpenIssueCount() {
- return ghRepository.getOpenIssueCount();
- }
-
- public Date getPushedAt() {
- return ghRepository.getPushedAt();
- }
-
- public Date getCreatedAt() {
- return ghRepository.getCreatedAt();
- }
-
- public String getMasterBranch() {
- return ghRepository.getMasterBranch();
- }
-
- public int getSize() {
- return ghRepository.getSize();
- }
-
- public GHPersonSet<GHUser> getCollaborators() throws IOException {
- return ghRepository.getCollaborators();
- }
-
- public Set<String> getCollaboratorNames() throws IOException {
- return ghRepository.getCollaboratorNames();
- }
-
- public Set<GHTeam> getTeams() throws IOException {
- return ghRepository.getTeams();
- }
-
- public void addCollaborators(GHUser... users) throws IOException {
- ghRepository.addCollaborators(users);
- }
-
- public void addCollaborators(Collection<GHUser> users) throws IOException {
- ghRepository.addCollaborators(users);
- }
-
- public void removeCollaborators(GHUser... users) throws IOException {
- ghRepository.removeCollaborators(users);
- }
-
- public void removeCollaborators(Collection<GHUser> users) throws IOException {
- ghRepository.removeCollaborators(users);
- }
-
- public void setEmailServiceHook(String address) throws IOException {
- ghRepository.setEmailServiceHook(address);
- }
-
- public void enableIssueTracker(boolean v) throws IOException {
- ghRepository.enableIssueTracker(v);
- }
-
- public void enableWiki(boolean v) throws IOException {
- ghRepository.enableWiki(v);
- }
-
- public void enableDownloads(boolean v) throws IOException {
- ghRepository.enableDownloads(v);
- }
-
- public void renameTo(String name) throws IOException {
- ghRepository.renameTo(name);
- }
-
- public void setDescription(String value) throws IOException {
- ghRepository.setDescription(value);
- }
-
- public void setHomepage(String value) throws IOException {
- ghRepository.setHomepage(value);
- }
-
- public void delete() throws IOException {
- ghRepository.delete();
- }
-
- public GHRepository fork() throws IOException {
- return ghRepository.fork();
- }
-
- public GHRepository forkTo(GHOrganization org) throws IOException {
- return ghRepository.forkTo(org);
- }
-
- public GHPullRequest getPullRequest(int i) throws IOException {
- return ghRepository.getPullRequest(i);
- }
-
- public List<GHPullRequest> getPullRequests(GHIssueState state)
- throws IOException {
- return ghRepository.getPullRequests(state);
- }
-
- public PagedIterable<GHPullRequest> listPullRequests(GHIssueState state) {
- return ghRepository.listPullRequests(state);
- }
-
- public List<GHHook> getHooks() throws IOException {
- return ghRepository.getHooks();
- }
-
- public GHHook getHook(int id) throws IOException {
- return ghRepository.getHook(id);
- }
-
- public GHCompare getCompare(String id1, String id2) throws IOException {
- return ghRepository.getCompare(id1, id2);
- }
-
- public GHCompare getCompare(GHCommit id1, GHCommit id2) throws IOException {
- return ghRepository.getCompare(id1, id2);
- }
-
- public GHCompare getCompare(GHBranch id1, GHBranch id2) throws IOException {
- return ghRepository.getCompare(id1, id2);
- }
-
- public GHRef[] getRefs() throws IOException {
- return ghRepository.getRefs();
- }
-
- public GHRef[] getRefs(String refType) throws IOException {
- return ghRepository.getRefs(refType);
- }
-
- public GHCommit getCommit(String sha1) throws IOException {
- return ghRepository.getCommit(sha1);
- }
-
- public PagedIterable<GHCommit> listCommits() {
- return ghRepository.listCommits();
- }
-
- public PagedIterable<GHCommitComment> listCommitComments() {
- return ghRepository.listCommitComments();
- }
-
- public PagedIterable<GHCommitStatus> listCommitStatuses(String sha1)
- throws IOException {
- return ghRepository.listCommitStatuses(sha1);
- }
-
- public GHCommitStatus getLastCommitStatus(String sha1) throws IOException {
- return ghRepository.getLastCommitStatus(sha1);
- }
-
- public GHCommitStatus createCommitStatus(String sha1, GHCommitState state,
- String targetUrl, String description) throws IOException {
- return ghRepository.createCommitStatus(sha1, state, targetUrl, description);
- }
-
- public PagedIterable<GHEventInfo> listEvents() throws IOException {
- return ghRepository.listEvents();
- }
-
- public GHHook createHook(String name, Map<String, String> config,
- Collection<GHEvent> events, boolean active) throws IOException {
- return ghRepository.createHook(name, config, events, active);
- }
-
- public GHHook createWebHook(URL url, Collection<GHEvent> events)
- throws IOException {
- return ghRepository.createWebHook(url, events);
- }
-
- public GHHook createWebHook(URL url) throws IOException {
- return ghRepository.createWebHook(url);
- }
-
- @SuppressWarnings("deprecation")
- public Set<URL> getPostCommitHooks() {
- return ghRepository.getPostCommitHooks();
- }
-
- public Map<String, GHBranch> getBranches() throws IOException {
- return ghRepository.getBranches();
- }
-
- @SuppressWarnings("deprecation")
- public Map<Integer, GHMilestone> getMilestones() throws IOException {
- return ghRepository.getMilestones();
- }
-
- public PagedIterable<GHMilestone> listMilestones(GHIssueState state) {
- return ghRepository.listMilestones(state);
- }
-
- public GHMilestone getMilestone(int number) throws IOException {
- return ghRepository.getMilestone(number);
- }
-
- public GHContent getFileContent(String path) throws IOException {
- return ghRepository.getFileContent(path);
- }
-
- public GHContent getFileContent(String path, String ref) throws IOException {
- return ghRepository.getFileContent(path, ref);
- }
-
- public List<GHContent> getDirectoryContent(String path) throws IOException {
- return ghRepository.getDirectoryContent(path);
- }
-
- public List<GHContent> getDirectoryContent(String path, String ref)
- throws IOException {
- return ghRepository.getDirectoryContent(path, ref);
- }
-
- public GHContent getReadme() throws Exception {
- return ghRepository.getReadme();
- }
-
- public GHContentUpdateResponse createContent(String content,
- String commitMessage, String path) throws IOException {
- return ghRepository.createContent(content, commitMessage, path);
- }
-
- public GHContentUpdateResponse createContent(String content,
- String commitMessage, String path, String branch) throws IOException {
- return ghRepository.createContent(content, commitMessage, path, branch);
- }
-
- public GHMilestone createMilestone(String title, String description)
- throws IOException {
- return ghRepository.createMilestone(title, description);
- }
-
- public String toString() {
- return ghRepository.toString();
- }
-
- public int hashCode() {
- return ghRepository.hashCode();
- }
-
- public boolean equals(Object obj) {
- return ghRepository.equals(obj);
- }
}