From: David ‘Bombe’ Roden Date: Thu, 14 Nov 2013 21:40:54 +0000 (+0100) Subject: Implement hashCode() and equals(). X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=5291d39fc7b95f5ba90dd75a403da374108382ba;p=Sone.git Implement hashCode() and equals(). --- diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityEvent.java b/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityEvent.java index 2727226..c262513 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityEvent.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityEvent.java @@ -68,4 +68,18 @@ public abstract class IdentityEvent { return identity; } + @Override + public int hashCode() { + return ownIdentity().hashCode() ^ identity().hashCode(); + } + + @Override + public boolean equals(Object object) { + if ((object == null) || !object.getClass().equals(getClass())) { + return false; + } + IdentityEvent identityEvent = (IdentityEvent) object; + return ownIdentity().equals(identityEvent.ownIdentity()) && identity().equals(identityEvent.identity()); + } + } diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityEvent.java b/src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityEvent.java index 97179e8..1216273 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityEvent.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityEvent.java @@ -52,4 +52,18 @@ public abstract class OwnIdentityEvent { return ownIdentity; } + @Override + public int hashCode() { + return ownIdentity().hashCode(); + } + + @Override + public boolean equals(Object object) { + if ((object == null) || !object.getClass().equals(getClass())) { + return false; + } + OwnIdentityEvent ownIdentityEvent = (OwnIdentityEvent) object; + return ownIdentity().equals(ownIdentityEvent.ownIdentity()); + } + }