Format all Java files with google-java-format

Change-Id: I05b6a2e93015e8a5a5e93cf64ad15b710e86b5c9
diff --git a/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/CreateReviewNotes.java b/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/CreateReviewNotes.java
index 249700a..69e48ca 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/CreateReviewNotes.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/CreateReviewNotes.java
@@ -40,7 +40,9 @@
 import com.google.inject.Inject;
 import com.google.inject.Provider;
 import com.google.inject.assistedinject.Assisted;
-
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
 import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException;
 import org.eclipse.jgit.errors.IncorrectObjectTypeException;
 import org.eclipse.jgit.errors.MissingObjectException;
@@ -58,18 +60,12 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-
 class CreateReviewNotes {
 
-  private static final Logger log =
-      LoggerFactory.getLogger(CreateReviewNotes.class);
+  private static final Logger log = LoggerFactory.getLogger(CreateReviewNotes.class);
 
   interface Factory {
-    CreateReviewNotes create(ReviewDb reviewDb, Project.NameKey project,
-        Repository git);
+    CreateReviewNotes create(ReviewDb reviewDb, Project.NameKey project, Repository git);
   }
 
   private static final String REFS_NOTES_REVIEW = "refs/notes/review";
@@ -94,7 +90,8 @@
   private StringBuilder message;
 
   @Inject
-  CreateReviewNotes(@GerritPersonIdent PersonIdent gerritIdent,
+  CreateReviewNotes(
+      @GerritPersonIdent PersonIdent gerritIdent,
       AccountCache accountCache,
       @AnonymousCowardName String anonymousCowardName,
       ProjectCache projectCache,
@@ -113,9 +110,11 @@
     this.anonymousCowardName = anonymousCowardName;
     ProjectState projectState = projectCache.get(project);
     if (projectState == null) {
-      log.error("Could not obtain available labels for project "
-          + project.get() + ". Expect missing labels in its review notes.");
-      this.labelTypes = new LabelTypes(Collections.<LabelType> emptyList());
+      log.error(
+          "Could not obtain available labels for project "
+              + project.get()
+              + ". Expect missing labels in its review notes.");
+      this.labelTypes = new LabelTypes(Collections.<LabelType>emptyList());
     } else {
       this.labelTypes = projectState.getLabelTypes();
     }
@@ -131,8 +130,9 @@
     this.git = git;
   }
 
-  void createNotes(String branch, ObjectId oldObjectId, ObjectId newObjectId,
-      ProgressMonitor monitor) throws OrmException, IOException {
+  void createNotes(
+      String branch, ObjectId oldObjectId, ObjectId newObjectId, ProgressMonitor monitor)
+      throws OrmException, IOException {
     if (ObjectId.zeroId().equals(newObjectId)) {
       return;
     }
@@ -158,8 +158,7 @@
       for (RevCommit c : rw) {
         PatchSet ps = loadPatchSet(c, branch);
         if (ps != null) {
-          ChangeNotes notes = notesFactory.create(reviewDb, project,
-              ps.getId().getParentKey());
+          ChangeNotes notes = notesFactory.create(reviewDb, project, ps.getId().getParentKey());
           ObjectId content = createNoteContent(notes, ps);
           if (content != null) {
             monitor.update(1);
@@ -167,8 +166,8 @@
             getMessage().append("* ").append(c.getShortMessage()).append("\n");
           }
         } else {
-          log.debug("no note for this commit since it is a direct push: "
-              + c.getName().substring(0, 7));
+          log.debug(
+              "no note for this commit since it is a direct push: " + c.getName().substring(0, 7));
         }
       }
     }
@@ -183,8 +182,7 @@
 
       for (ChangeNotes cn : notes) {
         monitor.update(1);
-        PatchSet ps =
-            reviewDb.patchSets().get(cn.getChange().currentPatchSetId());
+        PatchSet ps = reviewDb.patchSets().get(cn.getChange().currentPatchSetId());
         ObjectId commitId = ObjectId.fromString(ps.getRevision().get());
         RevCommit commit = rw.parseCommit(commitId);
         getNotes().set(commitId, createNoteContent(cn, ps));
@@ -200,9 +198,9 @@
       }
 
       message.insert(0, "Update notes for submitted changes\n\n");
-      notesBranchUtilFactory.create(project, git, inserter)
-          .commitAllNotes(reviewNotes, REFS_NOTES_REVIEW, gerritServerIdent,
-              message.toString());
+      notesBranchUtilFactory
+          .create(project, git, inserter)
+          .commitAllNotes(reviewNotes, REFS_NOTES_REVIEW, gerritServerIdent, message.toString());
     } finally {
       if (inserter != null) {
         inserter.close();
@@ -210,8 +208,7 @@
     }
   }
 
-  private void markUninteresting(Repository git, String branch, RevWalk rw,
-      ObjectId oldObjectId) {
+  private void markUninteresting(Repository git, String branch, RevWalk rw, ObjectId oldObjectId) {
     for (final Ref r : git.getAllRefs().values()) {
       try {
         if (r.getName().equals(branch)) {
@@ -236,13 +233,11 @@
 
   private ObjectId createNoteContent(ChangeNotes notes, PatchSet ps)
       throws OrmException, IOException {
-    HeaderFormatter fmt =
-        new HeaderFormatter(gerritServerIdent.getTimeZone(), anonymousCowardName);
+    HeaderFormatter fmt = new HeaderFormatter(gerritServerIdent.getTimeZone(), anonymousCowardName);
     if (ps != null) {
       try {
         createCodeReviewNote(notes, ps, fmt);
-        return getInserter().insert(Constants.OBJ_BLOB,
-            fmt.toString().getBytes("UTF-8"));
+        return getInserter().insert(Constants.OBJ_BLOB, fmt.toString().getBytes("UTF-8"));
       } catch (NoSuchChangeException e) {
         throw new IOException(e);
       }
@@ -250,11 +245,9 @@
     return null;
   }
 
-  private PatchSet loadPatchSet(RevCommit c, String destBranch)
-      throws OrmException {
+  private PatchSet loadPatchSet(RevCommit c, String destBranch) throws OrmException {
     String hash = c.name();
-    for (ChangeData cd : queryProvider.get()
-        .byBranchCommit(project.get(), destBranch, hash)) {
+    for (ChangeData cd : queryProvider.get().byBranchCommit(project.get(), destBranch, hash)) {
       for (PatchSet ps : cd.patchSets()) {
         if (ps.getRevision().matches(hash)) {
           return ps;
@@ -264,19 +257,18 @@
     return null; // TODO: createNoCodeReviewNote(branch, c, fmt);
   }
 
-  private void createCodeReviewNote(ChangeNotes notes, PatchSet ps,
-      HeaderFormatter fmt) throws OrmException, NoSuchChangeException {
+  private void createCodeReviewNote(ChangeNotes notes, PatchSet ps, HeaderFormatter fmt)
+      throws OrmException, NoSuchChangeException {
     // This races with the label normalization/writeback done by MergeOp. It may
     // repeat some work, but results should be identical except in the case of
     // an additional race with a permissions change.
     // TODO(dborowitz): These will eventually be stamped in the ChangeNotes at
     // commit time so we will be able to skip this normalization step.
     Change change = notes.getChange();
-    ChangeControl ctl = changeControlFactory.controlFor(
-        notes, userFactory.create(change.getOwner()));
+    ChangeControl ctl =
+        changeControlFactory.controlFor(notes, userFactory.create(change.getOwner()));
     PatchSetApproval submit = null;
-    for (PatchSetApproval a :
-        approvalsUtil.byPatchSet(reviewDb, ctl, ps.getId())) {
+    for (PatchSetApproval a : approvalsUtil.byPatchSet(reviewDb, ctl, ps.getId())) {
       if (a.getValue() == 0) {
         // Ignore 0 values.
       } else if (a.isLegacySubmit()) {
@@ -284,8 +276,7 @@
       } else {
         LabelType type = labelTypes.byLabel(a.getLabelId());
         if (type != null) {
-          fmt.appendApproval(type, a.getValue(),
-              accountCache.get(a.getAccountId()).getAccount());
+          fmt.appendApproval(type, a.getValue(), accountCache.get(a.getAccountId()).getAccount());
         }
       }
     }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/ExportReviewNotes.java b/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/ExportReviewNotes.java
index 7736652..9137e63 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/ExportReviewNotes.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/ExportReviewNotes.java
@@ -26,7 +26,9 @@
 import com.google.gwtorm.server.OrmException;
 import com.google.gwtorm.server.SchemaFactory;
 import com.google.inject.Inject;
-
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
 import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException;
 import org.eclipse.jgit.errors.RepositoryNotFoundException;
 import org.eclipse.jgit.lib.Repository;
@@ -34,26 +36,18 @@
 import org.eclipse.jgit.lib.ThreadSafeProgressMonitor;
 import org.kohsuke.args4j.Option;
 
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
 /** Export review notes for all submitted changes in all projects. */
 public class ExportReviewNotes extends SshCommand {
   @Option(name = "--threads", usage = "Number of concurrent threads to run")
   private int threads = 2;
 
-  @Inject
-  private GitRepositoryManager gitManager;
+  @Inject private GitRepositoryManager gitManager;
 
-  @Inject
-  private SchemaFactory<ReviewDb> database;
+  @Inject private SchemaFactory<ReviewDb> database;
 
-  @Inject
-  private CreateReviewNotes.Factory reviewNotesFactory;
+  @Inject private CreateReviewNotes.Factory reviewNotesFactory;
 
-  @Inject
-  private ChangeNotes.Factory notesFactory;
+  @Inject private ChangeNotes.Factory notesFactory;
 
   private ListMultimap<Project.NameKey, ChangeNotes> changes;
   private ThreadSafeProgressMonitor monitor;
@@ -86,8 +80,8 @@
     }
   }
 
-  private void export(ReviewDb db, Project.NameKey project,
-      List<ChangeNotes> notes) throws IOException, OrmException {
+  private void export(ReviewDb db, Project.NameKey project, List<ChangeNotes> notes)
+      throws IOException, OrmException {
     try (Repository git = gitManager.openRepository(project)) {
       CreateReviewNotes crn = reviewNotesFactory.create(db, project, git);
       crn.createNotes(notes, monitor);
@@ -114,7 +108,7 @@
     @Override
     public void run() {
       try (ReviewDb db = database.open()) {
-        for (;;) {
+        for (; ; ) {
           Map.Entry<Project.NameKey, List<ChangeNotes>> next = next();
           if (next != null) {
             try {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/HeaderFormatter.java b/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/HeaderFormatter.java
index 6bdb555..8633d5c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/HeaderFormatter.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/HeaderFormatter.java
@@ -18,7 +18,6 @@
 import com.google.gerrit.common.data.LabelValue;
 import com.google.gerrit.reviewdb.client.Account;
 import com.google.gerrit.reviewdb.client.Change;
-
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
@@ -28,11 +27,10 @@
 
 /**
  * Formatters for code review note headers.
- * <p>
- * This class provides a builder like interface for building the content of a
- * code review note. After instantiation, call as many as necessary
- * <code>append...(...)</code> methods and, at the end, call the
- * {@link #toString()} method to get the built note content.
+ *
+ * <p>This class provides a builder like interface for building the content of a code review note.
+ * After instantiation, call as many as necessary <code>append...(...)</code> methods and, at the
+ * end, call the {@link #toString()} method to get the built note content.
  */
 class HeaderFormatter {
 
@@ -41,8 +39,7 @@
   private final StringBuilder sb = new StringBuilder();
 
   HeaderFormatter(TimeZone tz, String anonymousCowardName) {
-    rfc2822DateFormatter =
-        new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.US);
+    rfc2822DateFormatter = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.US);
     rfc2822DateFormatter.setCalendar(Calendar.getInstance(tz, Locale.US));
     this.anonymousCowardName = anonymousCowardName;
   }
@@ -63,13 +60,13 @@
     boolean needSpace = false;
     boolean wroteData = false;
 
-    if (user.getFullName() != null && ! user.getFullName().isEmpty()) {
+    if (user.getFullName() != null && !user.getFullName().isEmpty()) {
       sb.append(user.getFullName());
       needSpace = true;
       wroteData = true;
     }
 
-    if (user.getPreferredEmail() != null && ! user.getPreferredEmail().isEmpty()) {
+    if (user.getPreferredEmail() != null && !user.getPreferredEmail().isEmpty()) {
       if (needSpace) {
         sb.append(" ");
       }
@@ -97,13 +94,11 @@
   }
 
   void appendSubmittedAt(Date date) {
-    sb.append("Submitted-at: ").append(rfc2822DateFormatter.format(date))
-        .append("\n");
+    sb.append("Submitted-at: ").append(rfc2822DateFormatter.format(date)).append("\n");
   }
 
   void appendReviewedOn(String canonicalWebUrl, Change.Id changeId) {
-    sb.append("Reviewed-on: ").append(canonicalWebUrl).append(changeId.get())
-        .append("\n");
+    sb.append("Reviewed-on: ").append(canonicalWebUrl).append(changeId.get()).append("\n");
   }
 
   @Override
diff --git a/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/RefUpdateListener.java b/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/RefUpdateListener.java
index d798648..24c9336 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/RefUpdateListener.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/RefUpdateListener.java
@@ -24,7 +24,7 @@
 import com.google.gwtorm.server.OrmException;
 import com.google.gwtorm.server.SchemaFactory;
 import com.google.inject.Inject;
-
+import java.io.IOException;
 import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException;
 import org.eclipse.jgit.lib.Config;
 import org.eclipse.jgit.lib.ObjectId;
@@ -32,12 +32,9 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.IOException;
-
 class RefUpdateListener implements GitReferenceUpdatedListener {
 
-  private static final Logger log = LoggerFactory
-      .getLogger(RefUpdateListener.class);
+  private static final Logger log = LoggerFactory.getLogger(RefUpdateListener.class);
 
   private final CreateReviewNotes.Factory reviewNotesFactory;
   private final SchemaFactory<ReviewDb> schema;
@@ -46,9 +43,11 @@
   private final boolean async;
 
   @Inject
-  RefUpdateListener(final CreateReviewNotes.Factory reviewNotesFactory,
+  RefUpdateListener(
+      final CreateReviewNotes.Factory reviewNotesFactory,
       final SchemaFactory<ReviewDb> schema,
-      final GitRepositoryManager repoManager, final WorkQueue workQueue,
+      final GitRepositoryManager repoManager,
+      final WorkQueue workQueue,
       @GerritServerConfig final Config config) {
     this.reviewNotesFactory = reviewNotesFactory;
     this.schema = schema;
@@ -59,32 +58,33 @@
 
   @Override
   public void onGitReferenceUpdated(final Event e) {
-    Runnable task = new ProjectRunnable() {
-      @Override
-      public void run() {
-        createReviewNotes(e);
-      }
+    Runnable task =
+        new ProjectRunnable() {
+          @Override
+          public void run() {
+            createReviewNotes(e);
+          }
 
-      @Override
-      public Project.NameKey getProjectNameKey() {
-        return new Project.NameKey(e.getProjectName());
-      }
+          @Override
+          public Project.NameKey getProjectNameKey() {
+            return new Project.NameKey(e.getProjectName());
+          }
 
-      @Override
-      public String getRemoteName() {
-        return null;
-      }
+          @Override
+          public String getRemoteName() {
+            return null;
+          }
 
-      @Override
-      public boolean hasCustomizedPrint() {
-        return true;
-      }
+          @Override
+          public boolean hasCustomizedPrint() {
+            return true;
+          }
 
-      @Override
-      public String toString() {
-        return "create-review-notes";
-      }
-    };
+          @Override
+          public String toString() {
+            return "create-review-notes";
+          }
+        };
     if (async) {
       workQueue.getDefaultQueue().submit(task);
     } else {
@@ -96,10 +96,10 @@
     Project.NameKey projectName = new Project.NameKey(e.getProjectName());
     try (Repository git = repoManager.openRepository(projectName);
         ReviewDb reviewDb = schema.open()) {
-      CreateReviewNotes crn = reviewNotesFactory.create(
-          reviewDb, projectName, git);
+      CreateReviewNotes crn = reviewNotesFactory.create(reviewDb, projectName, git);
       if (e.getRefName().startsWith("refs/heads/")) {
-        crn.createNotes(e.getRefName(),
+        crn.createNotes(
+            e.getRefName(),
             ObjectId.fromString(e.getOldObjectId()),
             ObjectId.fromString(e.getNewObjectId()),
             null);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/ReviewNotesModule.java b/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/ReviewNotesModule.java
index a2d4f79..83c50d6 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/ReviewNotesModule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/ReviewNotesModule.java
@@ -22,8 +22,7 @@
 public class ReviewNotesModule extends AbstractModule {
   @Override
   protected void configure() {
-    DynamicSet.bind(binder(), GitReferenceUpdatedListener.class)
-        .to(RefUpdateListener.class);
+    DynamicSet.bind(binder(), GitReferenceUpdatedListener.class).to(RefUpdateListener.class);
     install(new FactoryModuleBuilder().build(CreateReviewNotes.Factory.class));
   }
 }