Format all Java files with google-java-format

Change-Id: I18a72eee13a68608baeb4947ad848e46c5b2f51b
diff --git a/src/main/java/com/googlesource/gerrit/plugins/refprotection/BackupRef.java b/src/main/java/com/googlesource/gerrit/plugins/refprotection/BackupRef.java
index 884d1ab..b18d806 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/refprotection/BackupRef.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/refprotection/BackupRef.java
@@ -23,6 +23,10 @@
  */
 package com.googlesource.gerrit.plugins.refprotection;
 
+import static org.eclipse.jgit.lib.Constants.R_HEADS;
+import static org.eclipse.jgit.lib.Constants.R_REFS;
+import static org.eclipse.jgit.lib.Constants.R_TAGS;
+
 import com.google.gerrit.extensions.annotations.PluginName;
 import com.google.gerrit.extensions.api.projects.BranchInput;
 import com.google.gerrit.extensions.restapi.AuthException;
@@ -36,7 +40,9 @@
 import com.google.gerrit.server.project.CreateBranch;
 import com.google.gerrit.server.project.ProjectResource;
 import com.google.inject.Inject;
-
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import org.eclipse.jgit.errors.IncorrectObjectTypeException;
 import org.eclipse.jgit.errors.MissingObjectException;
 import org.eclipse.jgit.errors.RepositoryNotFoundException;
@@ -53,18 +59,9 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.eclipse.jgit.lib.Constants.R_HEADS;
-import static org.eclipse.jgit.lib.Constants.R_REFS;
-import static org.eclipse.jgit.lib.Constants.R_TAGS;
-
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
 public class BackupRef {
   public static final String R_BACKUPS = R_REFS + "backups/";
-  private static final Logger log =
-      LoggerFactory.getLogger(BackupRef.class);
+  private static final Logger log = LoggerFactory.getLogger(BackupRef.class);
   private final CreateBranch.Factory createBranchFactory;
   @Inject private static PluginConfigFactory cfg;
   @Inject private static GitRepositoryManager repoManager;
@@ -88,14 +85,11 @@
 
       try (RevWalk revWalk = new RevWalk(git)) {
         RefUpdateAttribute refUpdate = event.refUpdate.get();
-        if (cfg.getFromGerritConfig(pluginName).getBoolean("createTag",
-            false)) {
+        if (cfg.getFromGerritConfig(pluginName).getBoolean("createTag", false)) {
           TagBuilder tag = new TagBuilder();
           AccountAttribute submitter = event.submitter.get();
-          tag.setTagger(
-              new PersonIdent(submitter.name, submitter.email));
-          tag.setObjectId(revWalk
-              .parseCommit(ObjectId.fromString(refUpdate.oldRev)));
+          tag.setTagger(new PersonIdent(submitter.name, submitter.email));
+          tag.setObjectId(revWalk.parseCommit(ObjectId.fromString(refUpdate.oldRev)));
           String update = "Non-fast-forward update to";
           if (refUpdate.newRev.equals(ObjectId.zeroId().getName())) {
             update = "Deleted";
@@ -105,13 +99,14 @@
           if (refUpdate.refName.startsWith(R_TAGS)) {
             type = "tag";
             try {
-              RevTag origTag =
-                  revWalk.parseTag(ObjectId.fromString(refUpdate.oldRev));
+              RevTag origTag = revWalk.parseTag(ObjectId.fromString(refUpdate.oldRev));
               SimpleDateFormat format = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy ZZZZ");
               PersonIdent taggerIdent = origTag.getTaggerIdent();
               String tagger =
-                  String.format("Tagger: %s <%s>\nDate:   %s",
-                      taggerIdent.getName(), taggerIdent.getEmailAddress(),
+                  String.format(
+                      "Tagger: %s <%s>\nDate:   %s",
+                      taggerIdent.getName(),
+                      taggerIdent.getEmailAddress(),
                       format.format(taggerIdent.getWhen()));
               fullMessage = "\n\nOriginal tag:\n" + tagger + "\n\n" + origTag.getFullMessage();
             } catch (MissingObjectException e) {
@@ -130,8 +125,7 @@
           inserter.flush();
           RefUpdate tagRef = git.updateRef(tag.getTag());
           tagRef.setNewObjectId(tagId);
-          tagRef.setRefLogMessage("tagged deleted branch/tag " + tag.getTag(),
-              false);
+          tagRef.setRefLogMessage("tagged deleted branch/tag " + tag.getTag(), false);
           tagRef.setForceUpdate(false);
           Result result = tagRef.update();
           switch (result) {
@@ -156,14 +150,15 @@
           input.ref = backupRef;
           // We need to parse the commit to ensure if it's a tag, we get the
           // commit the tag points to!
-          input.revision = ObjectId.toString(
-              revWalk.parseCommit(ObjectId.fromString(refUpdate.oldRev))
-                  .getId());
+          input.revision =
+              ObjectId.toString(revWalk.parseCommit(ObjectId.fromString(refUpdate.oldRev)).getId());
 
           try {
             createBranchFactory.create(backupRef).apply(project, input);
-          } catch (BadRequestException | AuthException
-              | ResourceConflictException | IOException e) {
+          } catch (BadRequestException
+              | AuthException
+              | ResourceConflictException
+              | IOException e) {
             log.error(e.getMessage(), e);
           }
         }
@@ -178,15 +173,15 @@
   static String get(ProjectResource project, String refName) {
     if (cfg.getFromGerritConfig(pluginName).getBoolean("useTimestamp", true)) {
       return getTimestampBranch(refName);
-    }
-    else {
+    } else {
       return getSequentialBranch(project, refName);
     }
   }
 
   static String getTimestampBranch(String refName) {
     if (refName.startsWith(R_HEADS) || refName.startsWith(R_TAGS)) {
-      return String.format("%s-%s",
+      return String.format(
+          "%s-%s",
           R_BACKUPS + refName.replaceFirst(R_REFS, ""),
           new SimpleDateFormat("yyyyMMdd-HHmmss").format(new Date()));
     }
@@ -201,8 +196,7 @@
       for (Ref ref : git.getAllRefs().values()) {
         String name = ref.getName();
         if (name.startsWith(R_BACKUPS + deletedName + "/")) {
-          Integer thisNum =
-              Integer.parseInt(name.substring(name.lastIndexOf('/') + 1));
+          Integer thisNum = Integer.parseInt(name.substring(name.lastIndexOf('/') + 1));
           if (thisNum >= rev) {
             rev = thisNum + 1;
           }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/refprotection/RefProtectionModule.java b/src/main/java/com/googlesource/gerrit/plugins/refprotection/RefProtectionModule.java
index b2700c7..0f00282 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/refprotection/RefProtectionModule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/refprotection/RefProtectionModule.java
@@ -30,8 +30,7 @@
 public class RefProtectionModule extends AbstractModule {
   @Override
   protected void configure() {
-    DynamicSet.bind(binder(), EventListener.class).to(
-        RefUpdateListener.class);
+    DynamicSet.bind(binder(), EventListener.class).to(RefUpdateListener.class);
     requestStaticInjection(BackupRef.class);
   }
 }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/refprotection/RefUpdateListener.java b/src/main/java/com/googlesource/gerrit/plugins/refprotection/RefUpdateListener.java
index 0188990..bca99a1 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/refprotection/RefUpdateListener.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/refprotection/RefUpdateListener.java
@@ -26,8 +26,8 @@
 import static org.eclipse.jgit.lib.Constants.R_HEADS;
 import static org.eclipse.jgit.lib.Constants.R_TAGS;
 
-import com.google.gerrit.extensions.annotations.PluginName;
 import com.google.gerrit.common.EventListener;
+import com.google.gerrit.extensions.annotations.PluginName;
 import com.google.gerrit.reviewdb.client.Project;
 import com.google.gerrit.server.CurrentUser;
 import com.google.gerrit.server.config.PluginConfigFactory;
@@ -39,7 +39,7 @@
 import com.google.gerrit.server.project.ProjectControl;
 import com.google.gerrit.server.project.ProjectResource;
 import com.google.inject.Inject;
-
+import java.io.IOException;
 import org.eclipse.jgit.errors.RepositoryNotFoundException;
 import org.eclipse.jgit.lib.ObjectId;
 import org.eclipse.jgit.lib.Repository;
@@ -48,12 +48,9 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.IOException;
-
 class RefUpdateListener implements EventListener {
 
-  private static final Logger log =
-      LoggerFactory.getLogger(RefUpdateListener.class);
+  private static final Logger log = LoggerFactory.getLogger(RefUpdateListener.class);
   private final ProjectControl.GenericFactory projectControl;
   private final CurrentUser user;
   private final GitRepositoryManager repoManager;
@@ -62,7 +59,8 @@
   private final boolean protectFastForward;
 
   @Inject
-  RefUpdateListener(ProjectControl.GenericFactory p,
+  RefUpdateListener(
+      ProjectControl.GenericFactory p,
       CurrentUser user,
       GitRepositoryManager repoManager,
       BackupRef backupRef,
@@ -72,8 +70,7 @@
     this.user = user;
     this.repoManager = repoManager;
     this.backupRef = backupRef;
-    this.protectDeleted =
-        cfg.getFromGerritConfig(pluginName).getBoolean("protectDeleted", true);
+    this.protectDeleted = cfg.getFromGerritConfig(pluginName).getBoolean("protectDeleted", true);
     this.protectFastForward =
         cfg.getFromGerritConfig(pluginName).getBoolean("protectFastForward", true);
   }
@@ -81,15 +78,13 @@
   @Override
   public void onEvent(Event event) {
     if (event instanceof RefUpdatedEvent) {
-      RefUpdatedEvent refUpdate = (RefUpdatedEvent)event;
+      RefUpdatedEvent refUpdate = (RefUpdatedEvent) event;
       if ((protectDeleted || protectFastForward) && isRelevantRef(refUpdate)) {
         Project.NameKey nameKey = refUpdate.getProjectNameKey();
         try {
-          ProjectResource project =
-              new ProjectResource(projectControl.controlFor(nameKey, user));
+          ProjectResource project = new ProjectResource(projectControl.controlFor(nameKey, user));
           if ((protectDeleted && isRefDeleted(refUpdate))
-              || (protectFastForward && isNonFastForwardUpdate(refUpdate,
-                  project))) {
+              || (protectFastForward && isNonFastForwardUpdate(refUpdate, project))) {
             backupRef.createBackup(refUpdate, project);
           }
         } catch (NoSuchProjectException | IOException e) {
@@ -106,9 +101,8 @@
    * @return True if relevant, otherwise False.
    */
   private boolean isRelevantRef(RefUpdatedEvent event) {
-    return (!isNewRef(event)) &&
-           (event.getRefName().startsWith(R_HEADS)
-            || event.getRefName().startsWith(R_TAGS));
+    return (!isNewRef(event))
+        && (event.getRefName().startsWith(R_HEADS) || event.getRefName().startsWith(R_TAGS));
   }
 
   /**
@@ -130,9 +124,10 @@
   private boolean isRefDeleted(RefUpdatedEvent event) {
     RefUpdateAttribute refUpdate = event.refUpdate.get();
     if (refUpdate.newRev.equals(ObjectId.zeroId().getName())) {
-      log.info(String.format(
-          "Ref Deleted: project [%s] refname [%s] old object id [%s]",
-          event.getProjectNameKey().toString(), event.getRefName(), refUpdate.oldRev));
+      log.info(
+          String.format(
+              "Ref Deleted: project [%s] refname [%s] old object id [%s]",
+              event.getProjectNameKey().toString(), event.getRefName(), refUpdate.oldRev));
       return true;
     }
     return false;