Override Object methods.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 8 Nov 2013 17:46:06 +0000 (18:46 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 28 Feb 2014 21:25:55 +0000 (22:25 +0100)
src/main/java/net/pterodactylus/sone/text/PlainTextPart.java

index 7e677e5..95c8044 100644 (file)
 
 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());
+       }
+
 }