From 9a5a165a45db872e9e3a9292387cb3a6aa960992 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 3 Aug 2014 19:25:15 +0200 Subject: [PATCH] Require that truster and trustee are always non-null. --- .../java/net/pterodactylus/sone/core/WebOfTrustUpdater.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/core/WebOfTrustUpdater.java b/src/main/java/net/pterodactylus/sone/core/WebOfTrustUpdater.java index 9ad6478..2ed3487 100644 --- a/src/main/java/net/pterodactylus/sone/core/WebOfTrustUpdater.java +++ b/src/main/java/net/pterodactylus/sone/core/WebOfTrustUpdater.java @@ -360,8 +360,8 @@ public class WebOfTrustUpdater extends AbstractService { * The comment of the trust relation */ public SetTrustJob(OwnIdentity truster, Identity trustee, Integer score, String comment) { - this.truster = truster; - this.trustee = trustee; + this.truster = checkNotNull(truster, "truster must not be null"); + this.trustee = checkNotNull(trustee, "trustee must not be null"); this.score = score; this.comment = comment; } @@ -396,19 +396,19 @@ public class WebOfTrustUpdater extends AbstractService { return false; } SetTrustJob updateJob = (SetTrustJob) object; - return ((truster == null) ? (updateJob.truster == null) : updateJob.truster.equals(truster)) && ((trustee == null) ? (updateJob.trustee == null) : updateJob.trustee.equals(trustee)); + return updateJob.truster.equals(truster) && updateJob.trustee.equals(trustee); } /** {@inheritDoc} */ @Override public int hashCode() { - return getClass().hashCode() ^ ((truster == null) ? 0 : truster.hashCode()) ^ ((trustee == null) ? 0 : trustee.hashCode()); + return getClass().hashCode() ^ truster.hashCode() ^ trustee.hashCode(); } /** {@inheritDoc} */ @Override public String toString() { - return String.format("%s[truster=%s,trustee=%s]", getClass().getSimpleName(), (truster == null) ? null : truster.getId(), (trustee == null) ? null : trustee.getId()); + return String.format("%s[truster=%s,trustee=%s]", getClass().getSimpleName(), truster.getId(), trustee.getId()); } } -- 2.7.4