Implement hashCode() and equals().
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 14 Nov 2013 21:40:54 +0000 (22:40 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 26 Jun 2014 19:18:13 +0000 (21:18 +0200)
src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityEvent.java
src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityEvent.java

index 2727226..c262513 100644 (file)
@@ -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());
+       }
+
 }
index 97179e8..1216273 100644 (file)
@@ -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());
+       }
+
 }