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