From 4804cf24980777187bcac2b0dc2a8303c6e4f7a9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 20 Jul 2015 18:43:23 +0200 Subject: [PATCH] Override equals() and hashCode() --- .../java/net/pterodactylus/sone/data/impl/IdOnlySone.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/data/impl/IdOnlySone.java b/src/main/java/net/pterodactylus/sone/data/impl/IdOnlySone.java index 0ef220b..e9a0c57 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/IdOnlySone.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/IdOnlySone.java @@ -18,6 +18,8 @@ import net.pterodactylus.sone.freenet.wot.Identity; import freenet.keys.FreenetURI; +import com.google.common.base.Objects; + /** * {@link Sone} implementation that only stores the ID of a Sone and returns * {@code null}, {@code 0}, or empty collections where appropriate. @@ -240,4 +242,14 @@ public class IdOnlySone implements Sone { return id; } + @Override + public int hashCode() { + return id.hashCode(); + } + + @Override + public boolean equals(Object object) { + return (object != null) && (object.getClass() == getClass()) && Objects.equal(id, ((IdOnlySone) object).id); + } + } -- 2.7.4