Skip to content

Commit 4e690d9

Browse files
committed
[refactor] Java7: Use Object.equals for readability
1 parent 56c883d commit 4e690d9

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

exist-core/src/main/java/org/exist/collections/triggers/TriggerStatePerThread.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.ArrayDeque;
2828
import java.util.Deque;
2929
import java.util.Iterator;
30+
import java.util.Objects;
3031

3132
/**
3233
* Avoid infinite recursions in Triggers by preventing the same trigger
@@ -238,7 +239,7 @@ private boolean equals(final Object o, final boolean ignorePhase) {
238239
return false;
239240
}
240241

241-
return dst != null ? dst.equals(that.dst) : that.dst == null;
242+
return Objects.equals(dst, that.dst);
242243
}
243244

244245
private boolean equalsIgnoringPhase(final Trigger otherTrigger, final TriggerEvent otherTriggerEvent, final XmldbURI otherSrc, @Nullable final XmldbURI otherDst) {
@@ -254,7 +255,7 @@ private boolean equalsIgnoringPhase(final Trigger otherTrigger, final TriggerEve
254255
return false;
255256
}
256257

257-
return dst != null ? dst.equals(otherDst) : otherDst == null;
258+
return Objects.equals(dst, otherDst);
258259
}
259260

260261
public boolean isCompletedBy(final Trigger otherTrigger, final TriggerPhase otherTriggerPhase, final TriggerEvent otherTriggerEvent, final XmldbURI otherSrc, @Nullable final XmldbURI otherDst) {
@@ -275,7 +276,7 @@ public boolean isCompletedBy(final Trigger otherTrigger, final TriggerPhase othe
275276
return false;
276277
}
277278

278-
return dst != null ? dst.equals(otherDst) : otherDst == null;
279+
return Objects.equals(dst, otherDst);
279280
}
280281

281282
public boolean completes(final Object o) {
@@ -306,7 +307,7 @@ public boolean completes(final Object o) {
306307
return false;
307308
}
308309

309-
return dst != null ? dst.equals(that.dst) : that.dst == null;
310+
return Objects.equals(dst, that.dst);
310311
}
311312
}
312313
}

exist-core/src/main/java/org/exist/collections/triggers/XQueryTrigger.java

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,7 @@
2222
package org.exist.collections.triggers;
2323

2424
import java.io.IOException;
25-
import java.util.ArrayList;
26-
import java.util.EnumSet;
27-
import java.util.List;
28-
import java.util.Map;
29-
import java.util.Optional;
30-
import java.util.Properties;
31-
import java.util.Set;
25+
import java.util.*;
3226

3327
import org.apache.logging.log4j.LogManager;
3428
import org.apache.logging.log4j.Logger;
@@ -490,27 +484,27 @@ public boolean equals(final Object o) {
490484

491485
final XQueryTrigger that = (XQueryTrigger) o;
492486

493-
if (events != null ? !events.equals(that.events) : that.events != null) {
487+
if (!Objects.equals(events, that.events)) {
494488
return false;
495489
}
496490

497-
if (collection != null ? !collection.equals(that.collection) : that.collection != null) {
491+
if (!Objects.equals(collection, that.collection)) {
498492
return false;
499493
}
500494

501-
if (strQuery != null ? !strQuery.equals(that.strQuery) : that.strQuery != null) {
495+
if (!Objects.equals(strQuery, that.strQuery)) {
502496
return false;
503497
}
504498

505-
if (urlQuery != null ? !urlQuery.equals(that.urlQuery) : that.urlQuery != null) {
499+
if (!Objects.equals(urlQuery, that.urlQuery)) {
506500
return false;
507501
}
508502

509-
if (userDefinedVariables != null ? !userDefinedVariables.equals(that.userDefinedVariables) : that.userDefinedVariables != null) {
503+
if (!Objects.equals(userDefinedVariables, that.userDefinedVariables)) {
510504
return false;
511505
}
512506

513-
return bindingPrefix != null ? bindingPrefix.equals(that.bindingPrefix) : that.bindingPrefix == null;
507+
return Objects.equals(bindingPrefix, that.bindingPrefix);
514508
}
515509

516510
//Collection's methods

0 commit comments

Comments
 (0)