From: David ‘Bombe’ Roden Date: Fri, 8 Nov 2013 17:46:18 +0000 (+0100) Subject: Override hashCode() and equals(). X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=ed5632e10d991148b57de405f3d38b6d38ce3303;p=Sone.git Override hashCode() and equals(). --- 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()); + } + }