From aefc6e983ee277ffba8eb2aad6141911e100ae54 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 14 Nov 2013 22:40:54 +0100 Subject: [PATCH] Implement hashCode() and equals(). --- .../sone/freenet/wot/event/IdentityEvent.java | 14 ++++++++++++++ .../sone/freenet/wot/event/OwnIdentityEvent.java | 14 ++++++++++++++ 2 files changed, 28 insertions(+) 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()); + } + } -- 2.7.4