From ed5632e10d991148b57de405f3d38b6d38ce3303 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 8 Nov 2013 18:46:18 +0100 Subject: [PATCH] Override hashCode() and equals(). --- .../java/net/pterodactylus/sone/text/SonePart.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/text/SonePart.java b/src/main/java/net/pterodactylus/sone/text/SonePart.java index 7c0c34f..602ff05 100644 --- a/src/main/java/net/pterodactylus/sone/text/SonePart.java +++ b/src/main/java/net/pterodactylus/sone/text/SonePart.java @@ -17,9 +17,14 @@ package net.pterodactylus.sone.text; +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Objects.hashCode; + import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.template.SoneAccessor; +import com.google.common.base.Objects; + /** * {@link Part} implementation that stores a reference to a {@link Sone}. * @@ -62,4 +67,18 @@ public class SonePart implements Part { return SoneAccessor.getNiceName(sone); } + @Override + public int hashCode() { + return Objects.hashCode(sone); + } + + @Override + public boolean equals(Object object) { + if (!(object instanceof SonePart)) { + return false; + } + SonePart sonePart = (SonePart) object; + return equal(getSone(), sonePart.getSone()); + } + } -- 2.7.4