From 6ddf54f1380880aedc9049342cbd796a528d4208 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 14 Oct 2010 09:02:54 +0200 Subject: [PATCH] Override Object.hashCode() and Object.equals(). --- .../java/net/pterodactylus/sone/data/Post.java | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/data/Post.java b/src/main/java/net/pterodactylus/sone/data/Post.java index 9cf986f..3c02a1c 100644 --- a/src/main/java/net/pterodactylus/sone/data/Post.java +++ b/src/main/java/net/pterodactylus/sone/data/Post.java @@ -62,4 +62,28 @@ public class Post { return text; } + // + // OBJECT METHODS + // + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + return text.hashCode() ^ (int) (time >> 32) ^ (int) (time & 0xffffffff); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object object) { + if (!(object instanceof Post)) { + return false; + } + Post post = (Post) object; + return (post.time == time) && (post.text.equals(text)); + } + } -- 2.7.4