Skip to content

Commit 1370424

Browse files
author
Vladimir Kotal
committed
use Objects.equals()
1 parent 0b2a779 commit 1370424

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/history/History.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ public boolean equals(Object o) {
133133
return false;
134134
}
135135
History that = (History) o;
136-
return this.getHistoryEntries().equals(that.getHistoryEntries()) &&
137-
this.getRenamedFiles().equals(that.getRenamedFiles());
136+
return Objects.equals(this.getHistoryEntries(), that.getHistoryEntries()) &&
137+
Objects.equals(this.getRenamedFiles(), that.getRenamedFiles());
138138
}
139139

140140
@Override

opengrok-indexer/src/main/java/org/opengrok/indexer/history/HistoryEntry.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import java.util.Collection;
2727
import java.util.Date;
28+
import java.util.Objects;
2829
import java.util.SortedSet;
2930
import java.util.TreeSet;
3031
import java.util.logging.Level;
@@ -217,14 +218,6 @@ public void stripTags() {
217218
tags = null;
218219
}
219220

220-
private boolean checkEquals(Object o1, Object o2) {
221-
if (o1 != null && o2 != null) {
222-
return o1.equals(o2);
223-
}
224-
225-
return (o1 == null && o2 == null);
226-
}
227-
228221
private int getHashCode(Object o) {
229222
if (o == null) {
230223
return 0;
@@ -243,12 +236,12 @@ public boolean equals(Object o) {
243236
}
244237
HistoryEntry that = (HistoryEntry) o;
245238

246-
return checkEquals(this.getAuthor(), that.getAuthor()) &&
247-
checkEquals(this.getRevision(), that.getRevision()) &&
248-
checkEquals(this.getDate(), that.getDate()) &&
249-
checkEquals(this.getMessage(), that.getMessage()) &&
250-
checkEquals(this.getFiles(), that.getFiles()) &&
251-
checkEquals(this.getTags(), that.getTags());
239+
return Objects.equals(this.getAuthor(), that.getAuthor()) &&
240+
Objects.equals(this.getRevision(), that.getRevision()) &&
241+
Objects.equals(this.getDate(), that.getDate()) &&
242+
Objects.equals(this.getMessage(), that.getMessage()) &&
243+
Objects.equals(this.getFiles(), that.getFiles()) &&
244+
Objects.equals(this.getTags(), that.getTags());
252245
}
253246

254247
@Override

0 commit comments

Comments
 (0)