Skip to content

Commit

Permalink
Refactor file equality check
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Tian committed Jun 28, 2019
1 parent aa23d03 commit 55f3df7
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/main/java/net/wasdev/wlp/ant/types/EmbeddedServerInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.getAbsolutePath().equals(file2.getAbsolutePath())) {
return true;
}
return false;
}

public static class EmbeddedServers {
Expand Down

0 comments on commit 55f3df7

Please sign in to comment.