From 7ad37de9d3e8fa6103f127bc16690862a5b78a2f 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:46:06 +0100 Subject: [PATCH] Override Object methods. --- .../net/pterodactylus/sone/text/PlainTextPart.java | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/text/PlainTextPart.java b/src/main/java/net/pterodactylus/sone/text/PlainTextPart.java index 7e677e5..95c8044 100644 --- a/src/main/java/net/pterodactylus/sone/text/PlainTextPart.java +++ b/src/main/java/net/pterodactylus/sone/text/PlainTextPart.java @@ -17,6 +17,11 @@ package net.pterodactylus.sone.text; +import static com.google.common.base.Objects.equal; +import static java.lang.String.format; + +import com.google.common.base.Objects; + /** * {@link Part} implementation that holds a single piece of text. * @@ -46,4 +51,23 @@ public class PlainTextPart implements Part { return text; } + @Override + public int hashCode() { + return text.hashCode(); + } + + @Override + public boolean equals(Object object) { + if (!(object instanceof PlainTextPart)) { + return false; + } + PlainTextPart plainTextPart = (PlainTextPart) object; + return equal(getText(), plainTextPart.getText()); + } + + @Override + public String toString() { + return format("PlainText(%s)", getText()); + } + } -- 2.7.4