From 780d519851f9c66d507635bcda9d2044045bedaa 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:45:41 +0100 Subject: [PATCH] Add hashCode() and equals(). --- src/main/java/net/pterodactylus/sone/text/LinkPart.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/text/LinkPart.java b/src/main/java/net/pterodactylus/sone/text/LinkPart.java index de7cb25..a3f67ad 100644 --- a/src/main/java/net/pterodactylus/sone/text/LinkPart.java +++ b/src/main/java/net/pterodactylus/sone/text/LinkPart.java @@ -17,6 +17,8 @@ package net.pterodactylus.sone.text; +import static com.google.common.base.Objects.equal; + /** * {@link Part} implementation that can hold a link. A link contains of three * attributes: the link itself, the text that is shown instead of the link, and @@ -94,4 +96,18 @@ public class LinkPart implements Part { return text; } + @Override + public int hashCode() { + return getLink().hashCode() ^ (getTitle().hashCode() << 16) ^ getText().hashCode(); + } + + @Override + public boolean equals(Object object) { + if (!(object instanceof LinkPart)) { + return false; + } + LinkPart linkPart = (LinkPart) object; + return equal(getLink(), linkPart.getLink()) && equal(getText(), linkPart.getText()) && equal(getTitle(), linkPart.getTitle()); + } + } -- 2.7.4