Browse Source

code cleanup

Shinsuke Sugaya 4 years ago
parent
commit
53828fcb8e

+ 2 - 1
src/main/java/org/codelibs/fess/FessBoot.java

@@ -128,9 +128,10 @@ public class FessBoot extends TomcatBoot {
         return System.getProperty(TOMCAT_CONFIG_PATH);
     }
 
+    @Override
     protected void setupWebappContext() {
         super.setupWebappContext();
-        Context context = (Context) server.getHost().findChild(StringUtil.EMPTY);
+        final Context context = (Context) server.getHost().findChild(StringUtil.EMPTY);
         context.setResources(new FessWebResourceRoot(context));
     }
 }

+ 1 - 1
src/main/java/org/codelibs/fess/app/web/logout/LogoutAction.java

@@ -44,7 +44,7 @@ public class LogoutAction extends FessSearchAction {
 
     @Execute
     public HtmlResponse index() {
-        OptionalThing<FessUserBean> userBean = getUserBean();
+        final OptionalThing<FessUserBean> userBean = getUserBean();
         activityHelper.logout(userBean);
         final String redirectUrl = userBean.map(user -> ComponentUtil.getSsoManager().logout(user)).orElse(null);
         fessLoginAssist.logout();

+ 6 - 20
src/main/java/org/codelibs/fess/dict/kuromoji/KuromojiItem.java

@@ -15,6 +15,8 @@
  */
 package org.codelibs.fess.dict.kuromoji;
 
+import java.util.Objects;
+
 import org.codelibs.fess.dict.DictionaryItem;
 
 public class KuromojiItem extends DictionaryItem {
@@ -129,32 +131,16 @@ public class KuromojiItem extends DictionaryItem {
             return false;
         }
         final KuromojiItem other = (KuromojiItem) obj;
-        if (pos == null) {
-            if (other.pos != null) {
-                return false;
-            }
-        } else if (!pos.equals(other.pos)) {
+        if (!Objects.equals(pos, other.pos)) {
             return false;
         }
-        if (reading == null) {
-            if (other.reading != null) {
-                return false;
-            }
-        } else if (!reading.equals(other.reading)) {
+        if (!Objects.equals(reading, other.reading)) {
             return false;
         }
-        if (segmentation == null) {
-            if (other.segmentation != null) {
-                return false;
-            }
-        } else if (!segmentation.equals(other.segmentation)) {
+        if (!Objects.equals(segmentation, other.segmentation)) {
             return false;
         }
-        if (token == null) {
-            if (other.token != null) {
-                return false;
-            }
-        } else if (!token.equals(other.token)) {
+        if (!Objects.equals(token, other.token)) {
             return false;
         }
         return true;

+ 4 - 10
src/main/java/org/codelibs/fess/dict/stemmeroverride/StemmerOverrideItem.java

@@ -15,6 +15,8 @@
  */
 package org.codelibs.fess.dict.stemmeroverride;
 
+import java.util.Objects;
+
 import org.codelibs.core.lang.StringUtil;
 import org.codelibs.fess.dict.DictionaryItem;
 
@@ -92,18 +94,10 @@ public class StemmerOverrideItem extends DictionaryItem {
             return false;
         }
         final StemmerOverrideItem other = (StemmerOverrideItem) obj;
-        if (input == null) {
-            if (other.input != null) {
-                return false;
-            }
-        } else if (!input.equals(other.input)) {
+        if (!Objects.equals(input, other.input)) {
             return false;
         }
-        if (output == null) {
-            if (other.output != null) {
-                return false;
-            }
-        } else if (!output.equals(other.output)) {
+        if (!Objects.equals(output, other.output)) {
             return false;
         }
         return true;

+ 5 - 4
src/main/java/org/codelibs/fess/tomcat/webresources/FessWebResourceRoot.java

@@ -29,21 +29,22 @@ import org.apache.catalina.webresources.StandardRoot;
 public class FessWebResourceRoot extends StandardRoot {
     private static final Logger logger = Logger.getLogger(FessWebResourceRoot.class.getName());
 
-    public FessWebResourceRoot(Context context) {
+    public FessWebResourceRoot(final Context context) {
         super(context);
     }
 
+    @Override
     protected void processWebInfLib() throws LifecycleException {
         super.processWebInfLib();
 
-        WebResource[] possibleJars = listResources("/WEB-INF/plugin", false);
+        final WebResource[] possibleJars = listResources("/WEB-INF/plugin", false);
 
-        for (WebResource possibleJar : possibleJars) {
+        for (final WebResource possibleJar : possibleJars) {
             if (possibleJar.isFile() && possibleJar.getName().endsWith(".jar")) {
                 try (final JarFile jarFile = new JarFile(possibleJar.getCanonicalPath())) {
                     final Manifest manifest = jarFile.getManifest();
                     if (manifest != null && manifest.getEntries() != null) {
-                        Attributes attributes = manifest.getMainAttributes();
+                        final Attributes attributes = manifest.getMainAttributes();
                         if (attributes != null && attributes.get("Fess-WebAppJar") != null) {
                             createWebResourceSet(ResourceSetType.CLASSES_JAR, "/WEB-INF/classes", possibleJar.getURL(), "/");
                         }