From: David ‘Bombe’ Roden Date: Fri, 8 Nov 2013 17:46:06 +0000 (+0100) Subject: Override Object methods. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=7ad37de9d3e8fa6103f127bc16690862a5b78a2f;p=Sone.git Override Object methods. --- 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()); + } + }