From 4ec80e9d0845b260b2d5ae35a13ba7f595cd3ef7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 8 Nov 2013 20:13:03 +0100 Subject: [PATCH] Override equals() and hashCode(). --- src/main/java/net/pterodactylus/sone/text/PostPart.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/text/PostPart.java b/src/main/java/net/pterodactylus/sone/text/PostPart.java index 1e7eda1..f33055b 100644 --- a/src/main/java/net/pterodactylus/sone/text/PostPart.java +++ b/src/main/java/net/pterodactylus/sone/text/PostPart.java @@ -17,6 +17,8 @@ package net.pterodactylus.sone.text; +import static com.google.common.base.Objects.equal; + import net.pterodactylus.sone.data.Post; /** @@ -61,4 +63,18 @@ public class PostPart implements Part { return post.getText(); } + @Override + public int hashCode() { + return getPost().hashCode(); + } + + @Override + public boolean equals(Object object) { + if (!(object instanceof PostPart)) { + return false; + } + PostPart postPart = (PostPart) object; + return equal(getPost(), postPart.getPost()); + } + } -- 2.7.4