From 1c4770412bd0880013ca00532ff65b5a2bd94ac1 Mon Sep 17 00:00:00 2001
From: Luca Milanesio <luca.milanesio@gmail.com>
Date: Wed, 18 Jun 2014 16:26:25 +0100
Subject: [PATCH] Remove duplication of JarEntry comparator

Removed duplication of Comparator<JarEntry> in
the HttpPluginServlet, reducing the copy & paste
of the inner class in the code and improving
readability.

Change-Id: I71201779619435edac9ff70fa1fddd53fa80d373
---
 .../httpd/plugins/HttpPluginServlet.java      | 22 +++++++++----------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/plugins/HttpPluginServlet.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/plugins/HttpPluginServlet.java
index 215736e4a3..907760b69c 100644
--- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/plugins/HttpPluginServlet.java
+++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/plugins/HttpPluginServlet.java
@@ -83,6 +83,13 @@ class HttpPluginServlet extends HttpServlet
   private static final long serialVersionUID = 1L;
   private static final Logger log
       = LoggerFactory.getLogger(HttpPluginServlet.class);
+  private static final Comparator<JarEntry> JAR_ENTRY_COMPARATOR_BY_NAME =
+      new Comparator<JarEntry>() {
+        @Override
+        public int compare(JarEntry a, JarEntry b) {
+          return a.getName().compareTo(b.getName());
+        }
+      };
 
   private final MimeUtilFileTypeRegistry mimeUtil;
   private final Provider<String> webUrl;
@@ -369,18 +376,9 @@ class HttpPluginServlet extends HttpServlet
         }
       }
     }
-    Collections.sort(cmds, new Comparator<JarEntry>() {
-      @Override
-      public int compare(JarEntry a, JarEntry b) {
-        return a.getName().compareTo(b.getName());
-      }
-    });
-    Collections.sort(docs, new Comparator<JarEntry>() {
-      @Override
-      public int compare(JarEntry a, JarEntry b) {
-        return a.getName().compareTo(b.getName());
-      }
-    });
+
+    Collections.sort(cmds, JAR_ENTRY_COMPARATOR_BY_NAME);
+    Collections.sort(docs, JAR_ENTRY_COMPARATOR_BY_NAME);
 
     StringBuilder md = new StringBuilder();
     md.append(String.format("# Plugin %s #\n", pluginName));