Using Lombok at global level and removing public fields

It makes sense now to use Lombok for the entire
GitHub project (OAuth and Plugin) to leverage the 
automatic Getters and avoid exposing public fields
in the GitHubLogin.

Change-Id: I5eee0fe32a79916bd1a5c5380346b7847e9b6ef1
diff --git a/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/GitHubLogin.java b/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/GitHubLogin.java
index 6fb6fbe..9210fc2 100644
--- a/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/GitHubLogin.java
+++ b/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/GitHubLogin.java
@@ -29,6 +29,8 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import lombok.Getter;
+
 import org.apache.http.HttpStatus;
 import org.kohsuke.github.GHMyself;
 import org.kohsuke.github.GitHub;
@@ -57,8 +59,11 @@
     }
   }
 
-  public AccessToken token;
-  public GitHub hub;
+  @Getter
+  protected AccessToken token;
+
+  @Getter
+  protected GitHub hub;
 
   private transient OAuthProtocol oauth;
 
diff --git a/github-plugin/pom.xml b/github-plugin/pom.xml
index d6a84ef..9f61ef8 100644
--- a/github-plugin/pom.xml
+++ b/github-plugin/pom.xml
@@ -169,11 +169,5 @@
       <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 1896c04..7722d63 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
@@ -42,7 +42,7 @@
 
   public String getCloneUrl() {
     return cloneUrl.replace("://", "://" + ghLogin.getMyself().getLogin() + ":"
-        + ghLogin.token.access_token + "@");
+        + ghLogin.getToken().access_token + "@");
   }
 
   public String getOrganisation() {
@@ -63,6 +63,6 @@
     this.repository = repository;
     this.ghLogin = ghLoginProvider.get();
     this.ghRepository =
-        ghLogin.hub.getRepository(organisation + "/" + repository);
+        ghLogin.getHub().getRepository(organisation + "/" + repository);
   }
 }
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestImportJob.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestImportJob.java
index 8fe0468..3f199be 100644
--- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestImportJob.java
+++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestImportJob.java
@@ -274,7 +274,8 @@
     if (ghLogin.getMyself().getLogin().equals(organisation)) {
       return ghLogin.getMyself().getRepository(repoName);
     } else {
-      return ghLogin.hub.getOrganization(organisation).getRepository(repoName);
+      return ghLogin.getHub().getOrganization(organisation)
+          .getRepository(repoName);
     }
   }
 
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/ReplicateProjectStep.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/ReplicateProjectStep.java
index 50cf894..d4b52e8 100644
--- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/ReplicateProjectStep.java
+++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/ReplicateProjectStep.java
@@ -48,7 +48,7 @@
     this.replicationConfig = replicationConfig;
     GitHubLogin ghLogin = ghLoginProvider.get();
     this.authUsername = ghLogin.getMyself().getLogin();
-    this.authToken = ghLogin.token.access_token;
+    this.authToken = ghLogin.getToken().access_token;
     this.gitHubUrl = gitHubUrl;
   }
 
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/velocity/VelocityViewServlet.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/velocity/VelocityViewServlet.java
index 2035f9a..0d1cc41 100644
--- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/velocity/VelocityViewServlet.java
+++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/velocity/VelocityViewServlet.java
@@ -108,7 +108,7 @@
     GitHubLogin gitHubLogin = loginProvider.get(request);
     model.put("myself", gitHubLogin.getMyself());
     model.put("user", userProvider.get());
-    model.put("hub", gitHubLogin.hub);
+    model.put("hub", gitHubLogin.getHub());
 
     for (Entry<String, String[]> reqPar : request.getParameterMap().entrySet()) {
       model.put(reqPar.getKey(), reqPar.getValue());
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/PullRequestListController.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/PullRequestListController.java
index 0de40ff..4fad6ab 100644
--- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/PullRequestListController.java
+++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/PullRequestListController.java
@@ -129,7 +129,7 @@
     if (organisation.equals(hubLogin.getMyself().getLogin())) {
       ghOwner = hubLogin.getMyself();
     } else {
-      ghOwner = hubLogin.hub.getOrganization(organisation);
+      ghOwner = hubLogin.getHub().getOrganization(organisation);
     }
     return getPullRequests(
         hubLogin,
@@ -193,7 +193,7 @@
   private Optional<GHRepository> getGHRepository(GitHubLogin login,
       NameKey gerritRepoName) throws IOException {
     try {
-      return Optional.of(login.hub.getRepository(gerritRepoName.get()));
+      return Optional.of(login.getHub().getRepository(gerritRepoName.get()));
     } catch (FileNotFoundException e) {
       LOG.debug("GitHub repository {} cannot be found", gerritRepoName.get());
       return Optional.absent();
diff --git a/pom.xml b/pom.xml
index 154d840..1c22a9e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -279,4 +279,12 @@
       <url>https://gerrit-api.commondatastorage.googleapis.com/release/</url>
     </repository>
   </repositories>
+  <dependencies>
+    <dependency>
+        <groupId>org.projectlombok</groupId>
+        <artifactId>lombok</artifactId>
+        <version>1.14.0</version>
+        <scope>provided</scope>
+    </dependency>
+  </dependencies>
 </project>