From: David ‘Bombe’ Roden Date: Sun, 3 Aug 2014 17:25:15 +0000 (+0200) Subject: Require that truster and trustee are always non-null. X-Git-Tag: 0.9-rc1^2~3^2~171 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=9a5a165a45db872e9e3a9292387cb3a6aa960992;p=Sone.git Require that truster and trustee are always non-null. --- 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()); } }