Override Object methods.
[Sone.git] / 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());
+       }
+
 }