Format all Java files with google-java-format

Change-Id: Ia293230f3c4fdf8933e836dc4d0f7bf8c2814f9c
diff --git a/src/main/java/com/criteo/gerrit/plugins/automerge/AtomicityHelper.java b/src/main/java/com/criteo/gerrit/plugins/automerge/AtomicityHelper.java
index 1f4b11a..befccda 100644
--- a/src/main/java/com/criteo/gerrit/plugins/automerge/AtomicityHelper.java
+++ b/src/main/java/com/criteo/gerrit/plugins/automerge/AtomicityHelper.java
@@ -32,63 +32,46 @@
 import com.google.gwtorm.server.OrmException;
 import com.google.inject.Inject;
 import com.google.inject.Provider;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import java.io.IOException;
 import java.util.List;
 import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class AtomicityHelper {
 
-  private final static Logger log = LoggerFactory.getLogger(AtomicityHelper.class);
+  private static final Logger log = LoggerFactory.getLogger(AtomicityHelper.class);
 
-  @Inject
-  ChangeData.Factory changeDataFactory;
+  @Inject ChangeData.Factory changeDataFactory;
 
-  @Inject
-  private ChangesCollection collection;
+  @Inject private ChangesCollection collection;
 
-  @Inject
-  AutomergeConfig config;
+  @Inject AutomergeConfig config;
 
-  @Inject
-  Provider<ReviewDb> db;
+  @Inject Provider<ReviewDb> db;
 
-  @Inject
-  private IdentifiedUser.GenericFactory factory;
+  @Inject private IdentifiedUser.GenericFactory factory;
 
-  @Inject
-  GetRelated getRelated;
+  @Inject GetRelated getRelated;
 
-  @Inject
-  MergeUtil.Factory mergeUtilFactory;
+  @Inject MergeUtil.Factory mergeUtilFactory;
 
-  @Inject
-  Provider<PostReview> reviewer;
+  @Inject Provider<PostReview> reviewer;
 
-  @Inject
-  AccountCache accountCache;
+  @Inject AccountCache accountCache;
 
-  @Inject
-  Accounts accounts;
+  @Inject Accounts accounts;
 
-  @Inject
-  Submit submitter;
+  @Inject Submit submitter;
 
-  @Inject
-  Emails emails;
+  @Inject Emails emails;
 
-  @Inject
-  ChangeNotes.Factory changeNotesFactory;
+  @Inject ChangeNotes.Factory changeNotesFactory;
 
-  @Inject
-  PermissionBackend permissionBackend;
+  @Inject PermissionBackend permissionBackend;
 
   /**
-   * Check if the current patchset of the specified change has dependent
-   * unmerged changes.
+   * Check if the current patchset of the specified change has dependent unmerged changes.
    *
    * @param project
    * @param number
@@ -97,23 +80,25 @@
    * @throws NoSuchChangeException
    * @throws OrmException
    */
-  public boolean hasDependentReview(String project, int number) throws IOException, NoSuchChangeException, OrmException {
-      RevisionResource r = getRevisionResource(project, number);
+  public boolean hasDependentReview(String project, int number)
+      throws IOException, NoSuchChangeException, OrmException {
+    RevisionResource r = getRevisionResource(project, number);
     RelatedInfo related = getRelated.apply(r);
     log.debug(String.format("Checking for related changes on review %d", number));
     return related.changes.size() > 0;
   }
 
   /**
-   * Check if a change is an atomic change or not. A change is atomic if it has
-   * the atomic topic prefix.
+   * Check if a change is an atomic change or not. A change is atomic if it has the atomic topic
+   * prefix.
    *
    * @param change a ChangeAttribute instance
    * @return true or false
    */
   public boolean isAtomicReview(final ChangeAttribute change) {
     final boolean atomic = change.topic != null && change.topic.startsWith(config.getTopicPrefix());
-    log.debug(String.format("Checking if change %s is an atomic change: %b", change.number, atomic));
+    log.debug(
+        String.format("Checking if change %s is an atomic change: %b", change.number, atomic));
     return atomic;
   }
 
@@ -126,9 +111,13 @@
    * @throws OrmException
    */
   public boolean isSubmittable(String project, int change) throws OrmException {
-    ChangeData changeData = changeDataFactory.create(db.get(), new Project.NameKey(project), new Change.Id(change));
+    ChangeData changeData =
+        changeDataFactory.create(db.get(), new Project.NameKey(project), new Change.Id(change));
     // For draft reviews, the patchSet must be set to avoid an NPE.
-    final List<SubmitRecord> cansubmit = new SubmitRuleEvaluator(accountCache, accounts, emails, changeData).setPatchSet(changeData.currentPatchSet()).evaluate();
+    final List<SubmitRecord> cansubmit =
+        new SubmitRuleEvaluator(accountCache, accounts, emails, changeData)
+            .setPatchSet(changeData.currentPatchSet())
+            .evaluate();
     log.debug(String.format("Checking if change %d is submitable.", change));
     for (SubmitRecord submit : cansubmit) {
       if (submit.status != SubmitRecord.Status.OK) {
@@ -146,21 +135,19 @@
    * @param info
    */
   public void mergeReview(ChangeInfo info) throws Exception {
-    submitter.apply(getRevisionResource(info.project, info._number),
-        new SubmitInput());
+    submitter.apply(getRevisionResource(info.project, info._number), new SubmitInput());
   }
 
-  public RevisionResource getRevisionResource(String project, int changeNumber) throws NoSuchChangeException, OrmException {
+  public RevisionResource getRevisionResource(String project, int changeNumber)
+      throws NoSuchChangeException, OrmException {
     Change.Id changeId = new Change.Id(changeNumber);
     ChangeNotes notes = changeNotesFactory.createChecked(changeId);
     try {
-      permissionBackend
-        .user(getBotUser())
-        .change(notes)
-        .database(db)
-        .check(READ);
-      ChangeData changeData = changeDataFactory.create(db.get(), new Project.NameKey(project), changeId);
-      RevisionResource r = new RevisionResource(collection.parse(changeId), changeData.currentPatchSet());
+      permissionBackend.user(getBotUser()).change(notes).database(db).check(READ);
+      ChangeData changeData =
+          changeDataFactory.create(db.get(), new Project.NameKey(project), changeId);
+      RevisionResource r =
+          new RevisionResource(collection.parse(changeId), changeData.currentPatchSet());
       return r;
     } catch (ResourceNotFoundException | AuthException | PermissionBackendException e) {
       throw new NoSuchChangeException(changeId);
diff --git a/src/main/java/com/criteo/gerrit/plugins/automerge/AutomaticMerger.java b/src/main/java/com/criteo/gerrit/plugins/automerge/AutomaticMerger.java
index e83f47b..2e20bc1 100644
--- a/src/main/java/com/criteo/gerrit/plugins/automerge/AutomaticMerger.java
+++ b/src/main/java/com/criteo/gerrit/plugins/automerge/AutomaticMerger.java
@@ -18,8 +18,8 @@
 import com.google.gerrit.common.EventListener;
 import com.google.gerrit.extensions.api.GerritApi;
 import com.google.gerrit.extensions.api.changes.ChangeApi;
-import com.google.gerrit.extensions.common.ChangeInfo;
 import com.google.gerrit.extensions.client.ListChangesOption;
+import com.google.gerrit.extensions.common.ChangeInfo;
 import com.google.gerrit.extensions.events.LifecycleListener;
 import com.google.gerrit.extensions.restapi.RestApiException;
 import com.google.gerrit.reviewdb.server.ReviewDb;
@@ -37,61 +37,44 @@
 import com.google.gerrit.server.query.change.ChangeData;
 import com.google.inject.Inject;
 import com.google.inject.Provider;
-
+import java.util.EnumSet;
+import java.util.List;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.EnumSet;
-import java.util.List;
-
-/**
- * Starts at the same time as the gerrit server, and sets up our change hook
- * listener.
- */
+/** Starts at the same time as the gerrit server, and sets up our change hook listener. */
 public class AutomaticMerger implements EventListener, LifecycleListener {
 
-  private final static Logger log = LoggerFactory.getLogger(AutomaticMerger.class);
+  private static final Logger log = LoggerFactory.getLogger(AutomaticMerger.class);
 
-  @Inject
-  private GerritApi api;
+  @Inject private GerritApi api;
 
-  @Inject
-  private AtomicityHelper atomicityHelper;
+  @Inject private AtomicityHelper atomicityHelper;
 
-  @Inject
-  ChangeData.Factory changeDataFactory;
+  @Inject ChangeData.Factory changeDataFactory;
 
-  @Inject
-  private AutomergeConfig config;
+  @Inject private AutomergeConfig config;
 
-  @Inject
-  Provider<ReviewDb> db;
+  @Inject Provider<ReviewDb> db;
 
-  @Inject
-  GetRelated getRelated;
+  @Inject GetRelated getRelated;
 
-  @Inject
-  MergeUtil.Factory mergeUtilFactory;
+  @Inject MergeUtil.Factory mergeUtilFactory;
 
-  @Inject
-  Provider<PostReview> reviewer;
+  @Inject Provider<PostReview> reviewer;
 
-  @Inject
-  private ReviewUpdater reviewUpdater;
+  @Inject private ReviewUpdater reviewUpdater;
 
-  @Inject
-  Submit submitter;
+  @Inject Submit submitter;
 
   @Override
-  synchronized public void onEvent(final Event event) {
+  public synchronized void onEvent(final Event event) {
     if (event instanceof TopicChangedEvent) {
-      onTopicChanged((TopicChangedEvent)event);
-    }
-    else if (event instanceof PatchSetCreatedEvent) {
-      onPatchSetCreated((PatchSetCreatedEvent)event);
-    }
-    else if (event instanceof CommentAddedEvent) {
-      onCommentAdded((CommentAddedEvent)event);
+      onTopicChanged((TopicChangedEvent) event);
+    } else if (event instanceof PatchSetCreatedEvent) {
+      onPatchSetCreated((PatchSetCreatedEvent) event);
+    } else if (event instanceof CommentAddedEvent) {
+      onCommentAdded((CommentAddedEvent) event);
     }
   }
 
@@ -133,14 +116,16 @@
 
   private void autoSubmitIfMergeable(ChangeAttribute change) throws Exception {
     if (atomicityHelper.isSubmittable(change.project, change.number)) {
-      log.info(String.format("Change %d is submittable. Will try to merge all related changes.", change.number));
+      log.info(
+          String.format(
+              "Change %d is submittable. Will try to merge all related changes.", change.number));
       attemptToMerge(change);
     }
   }
 
   /**
-   * Returns true if the plugin must handle this comment, i.e. if we are sure it does not come
-   * from this plugin (to avoid infinite loop).
+   * Returns true if the plugin must handle this comment, i.e. if we are sure it does not come from
+   * this plugin (to avoid infinite loop).
    *
    * @param comment
    * @return a boolean
@@ -165,8 +150,11 @@
   private void attemptToMerge(ChangeAttribute change) throws Exception {
     final List<ChangeInfo> related = Lists.newArrayList();
     if (atomicityHelper.isAtomicReview(change)) {
-      related.addAll(api.changes().query("status: open AND topic: " + change.topic)
-          .withOption(ListChangesOption.CURRENT_REVISION).get());
+      related.addAll(
+          api.changes()
+              .query("status: open AND topic: " + change.topic)
+              .withOption(ListChangesOption.CURRENT_REVISION)
+              .get());
     } else {
       ChangeApi changeApi = api.changes().id(change.project, change.branch, change.id);
       related.add(changeApi.get(EnumSet.of(ListChangesOption.CURRENT_REVISION)));
@@ -189,7 +177,8 @@
           atomicityHelper.mergeReview(info);
         }
       } else {
-	  reviewUpdater.commentOnReview(change.project, change.number, AutomergeConfig.CANT_MERGE_COMMENT_FILE);
+        reviewUpdater.commentOnReview(
+            change.project, change.number, AutomergeConfig.CANT_MERGE_COMMENT_FILE);
       }
     }
   }
@@ -198,12 +187,16 @@
     try {
       checkReviewExists(change.number);
       if (atomicityHelper.hasDependentReview(change.project, change.number)) {
-        log.info(String.format("Warn the user by setting -1 on change %d, as other atomic changes exists on the same repository.",
-            change.number));
-        reviewUpdater.setMinusOne(change.project, change.number, AutomergeConfig.ATOMIC_REVIEWS_SAME_REPO_FILE);
+        log.info(
+            String.format(
+                "Warn the user by setting -1 on change %d, as other atomic changes exists on the same repository.",
+                change.number));
+        reviewUpdater.setMinusOne(
+            change.project, change.number, AutomergeConfig.ATOMIC_REVIEWS_SAME_REPO_FILE);
       } else {
         log.info(String.format("Detected atomic review on change %d.", change.number));
-        reviewUpdater.commentOnReview(change.project, change.number, AutomergeConfig.ATOMIC_REVIEW_DETECTED_FILE);
+        reviewUpdater.commentOnReview(
+            change.project, change.number, AutomergeConfig.ATOMIC_REVIEW_DETECTED_FILE);
       }
     } catch (Exception e) {
       throw new RuntimeException(e);
@@ -220,6 +213,5 @@
   }
 
   @Override
-  public void stop() {
-  }
+  public void stop() {}
 }
diff --git a/src/main/java/com/criteo/gerrit/plugins/automerge/AutomergeConfig.java b/src/main/java/com/criteo/gerrit/plugins/automerge/AutomergeConfig.java
index bd1bbca..44a0ed1 100644
--- a/src/main/java/com/criteo/gerrit/plugins/automerge/AutomergeConfig.java
+++ b/src/main/java/com/criteo/gerrit/plugins/automerge/AutomergeConfig.java
@@ -3,22 +3,20 @@
 import com.google.gerrit.server.config.GerritServerConfig;
 import com.google.gerrit.server.config.SitePaths;
 import com.google.inject.Inject;
-
-import org.eclipse.jgit.lib.Config;
-
 import java.io.File;
+import org.eclipse.jgit.lib.Config;
 
 public class AutomergeConfig {
 
-  public final static String ATOMIC_REVIEW_DETECTED_FILE = "atomic_review_detected.txt";
-  public final static String ATOMIC_REVIEWS_SAME_REPO_FILE = "atomic_review_same_repo.txt";
-  public final static String AUTOMERGE_SECTION = "automerge";
-  public final static String BOT_EMAIL_KEY = "botEmail";
-  public final static String CANT_MERGE_COMMENT_FILE = "cantmerge.txt";
+  public static final String ATOMIC_REVIEW_DETECTED_FILE = "atomic_review_detected.txt";
+  public static final String ATOMIC_REVIEWS_SAME_REPO_FILE = "atomic_review_same_repo.txt";
+  public static final String AUTOMERGE_SECTION = "automerge";
+  public static final String BOT_EMAIL_KEY = "botEmail";
+  public static final String CANT_MERGE_COMMENT_FILE = "cantmerge.txt";
 
-  private final static String defaultBotEmail = "qabot@criteo.com";
-  private final static String defaultTopicPrefix = "crossrepo/";
-  public final static String TOPIC_PREFIX_KEY = "topicPrefix";
+  private static final String defaultBotEmail = "qabot@criteo.com";
+  private static final String defaultTopicPrefix = "crossrepo/";
+  public static final String TOPIC_PREFIX_KEY = "topicPrefix";
 
   public static final String getDefaultBotEmail() {
     return defaultBotEmail;
diff --git a/src/main/java/com/criteo/gerrit/plugins/automerge/AutomergeModule.java b/src/main/java/com/criteo/gerrit/plugins/automerge/AutomergeModule.java
index 744bb2d..dda0aa5 100644
--- a/src/main/java/com/criteo/gerrit/plugins/automerge/AutomergeModule.java
+++ b/src/main/java/com/criteo/gerrit/plugins/automerge/AutomergeModule.java
@@ -21,7 +21,7 @@
 /**
  * Main automerge Guice module.
  *
- * Configures how all classes in the plugin are instantiated via Guice.
+ * <p>Configures how all classes in the plugin are instantiated via Guice.
  */
 public class AutomergeModule extends AbstractModule {
 
diff --git a/src/main/java/com/criteo/gerrit/plugins/automerge/ReviewUpdater.java b/src/main/java/com/criteo/gerrit/plugins/automerge/ReviewUpdater.java
index 9c1285f..7a23693 100644
--- a/src/main/java/com/criteo/gerrit/plugins/automerge/ReviewUpdater.java
+++ b/src/main/java/com/criteo/gerrit/plugins/automerge/ReviewUpdater.java
@@ -9,37 +9,30 @@
 import com.google.gerrit.server.query.change.ChangeData;
 import com.google.inject.Inject;
 import com.google.inject.Provider;
-
+import java.io.File;
+import java.io.IOException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.File;
-import java.io.IOException;
-
 public class ReviewUpdater {
-  private final static Logger log = LoggerFactory.getLogger(AutomaticMerger.class);
+  private static final Logger log = LoggerFactory.getLogger(AutomaticMerger.class);
 
-  @Inject
-  ChangeData.Factory changeDataFactory;
+  @Inject ChangeData.Factory changeDataFactory;
 
-  @Inject
-  AutomergeConfig config;
+  @Inject AutomergeConfig config;
 
-  @Inject
-  Provider<ReviewDb> db;
+  @Inject Provider<ReviewDb> db;
 
-  @Inject
-  Provider<PostReview> reviewer;
+  @Inject Provider<PostReview> reviewer;
 
-  @Inject
-  private AtomicityHelper atomicityHelper;
+  @Inject private AtomicityHelper atomicityHelper;
 
   public void commentOnReview(String project, int number, String commentTemplate) throws Exception {
     ReviewInput comment = createComment(commentTemplate);
     applyComment(project, number, comment);
   }
 
-    public void setMinusOne(String project, int number, String commentTemplate) throws Exception {
+  public void setMinusOne(String project, int number, String commentTemplate) throws Exception {
     ReviewInput message = createComment(commentTemplate).label("Code-Review", -1);
     applyComment(project, number, message);
   }
@@ -49,15 +42,17 @@
   }
 
   private String getCommentFromFile(final String filename) {
-     try {
-       return Files.toString(new File(config.getTemplatesPath(), filename), Charsets.UTF_8);
-     } catch (final IOException exc) {
-       final String errmsg =
-           String.format("Cannot find %s file in gerrit etc dir. Please check your gerrit configuration", filename);
-       log.error(errmsg);
-       return errmsg;
-     }
-   }
+    try {
+      return Files.toString(new File(config.getTemplatesPath(), filename), Charsets.UTF_8);
+    } catch (final IOException exc) {
+      final String errmsg =
+          String.format(
+              "Cannot find %s file in gerrit etc dir. Please check your gerrit configuration",
+              filename);
+      log.error(errmsg);
+      return errmsg;
+    }
+  }
 
   private void applyComment(String project, int number, ReviewInput comment) throws Exception {
     RevisionResource r = atomicityHelper.getRevisionResource(project, number);
diff --git a/src/test/java/com/criteo/gerrit/plugins/automerge/AutomergeConfigTest.java b/src/test/java/com/criteo/gerrit/plugins/automerge/AutomergeConfigTest.java
index 49535db..69e4ef9 100644
--- a/src/test/java/com/criteo/gerrit/plugins/automerge/AutomergeConfigTest.java
+++ b/src/test/java/com/criteo/gerrit/plugins/automerge/AutomergeConfigTest.java
@@ -4,13 +4,11 @@
 import static org.junit.Assert.fail;
 
 import com.google.gerrit.server.config.SitePaths;
-
-import org.eclipse.jgit.lib.Config;
-import org.junit.Test;
-
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.nio.file.Paths;
+import org.eclipse.jgit.lib.Config;
+import org.junit.Test;
 
 public class AutomergeConfigTest {
 
@@ -35,8 +33,13 @@
     try {
       final SitePaths paths = new SitePaths(Paths.get("."));
 
-      conf.setString(AutomergeConfig.AUTOMERGE_SECTION, null, AutomergeConfig.BOT_EMAIL_KEY, "Foo@bar.com");
-      conf.setString(AutomergeConfig.AUTOMERGE_SECTION, null, AutomergeConfig.TOPIC_PREFIX_KEY, "fake_topic_prefix");
+      conf.setString(
+          AutomergeConfig.AUTOMERGE_SECTION, null, AutomergeConfig.BOT_EMAIL_KEY, "Foo@bar.com");
+      conf.setString(
+          AutomergeConfig.AUTOMERGE_SECTION,
+          null,
+          AutomergeConfig.TOPIC_PREFIX_KEY,
+          "fake_topic_prefix");
 
       final AutomergeConfig amconf = new AutomergeConfig(conf, paths);
       assertEquals(amconf.getBotEmail(), "Foo@bar.com");