From aa6d39bd27c76a5bbe8b0178fc0a7287e15b6468 Mon Sep 17 00:00:00 2001 From: Charles Tian Date: Fri, 28 Jun 2019 09:40:50 -0500 Subject: [PATCH] Refactor file equality check --- .../wlp/ant/types/EmbeddedServerInfo.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/wasdev/wlp/ant/types/EmbeddedServerInfo.java b/src/main/java/net/wasdev/wlp/ant/types/EmbeddedServerInfo.java index 36badaff..78360e18 100644 --- a/src/main/java/net/wasdev/wlp/ant/types/EmbeddedServerInfo.java +++ b/src/main/java/net/wasdev/wlp/ant/types/EmbeddedServerInfo.java @@ -49,13 +49,19 @@ public File getOutputDir() { public boolean equals(EmbeddedServerInfo info) { return - this.serverName.equals(info.serverName) - && ( (this.userDir == null && info.userDir == null) || - (this.userDir != null && info.userDir != null && - this.userDir.getAbsolutePath().equals(info.userDir.getAbsolutePath())) ) - && ( (this.outputDir == null && info.outputDir == null) || - (this.outputDir != null && info.outputDir != null && - this.outputDir.getAbsolutePath().equals(info.outputDir.getAbsolutePath())) ); + this.serverName.equals(info.serverName) && + filesEqual(this.userDir, info.userDir) && + filesEqual(this.outputDir, info.outputDir); + } + + private boolean filesEqual(File file1, File file2) { + if(file1 == null && file2 == null) { + return true; + } + if(file1 != null && file2 != null && file1.getAbsolutePath().equals(file2.getAbsolutePath())) { + return true; + } + return false; } public static class EmbeddedServers {