/*
- * Sone - LinkPart.java - Copyright © 2011 David Roden
+ * Sone - LinkPart.java - Copyright © 2011–2013 David Roden
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
package net.pterodactylus.sone.text;
+import static com.google.common.base.Objects.equal;
+
/**
* {@link Part} implementation that can hold a link. A link contains of three
* attributes: the link itself, the text that is shown instead of the link, and
}
/**
- * Returns the text of this part.
- *
- * @return The text of this part
- */
- public String getText() {
- return text;
- }
-
- /**
* Returns the title of this part.
*
* @return The title of this part
return title;
}
+ @Override
+ public boolean isPlainText() {
+ return false;
+ }
+
+ @Override
+ public boolean isFreenetLink() {
+ return false;
+ }
+
+ //
+ // PART METHODS
+ //
+
+ @Override
+ public String getText() {
+ return text;
+ }
+
+ @Override
+ public int hashCode() {
+ return getLink().hashCode() ^ (getTitle().hashCode() << 16) ^ getText().hashCode();
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof LinkPart)) {
+ return false;
+ }
+ LinkPart linkPart = (LinkPart) object;
+ return equal(getLink(), linkPart.getLink()) && equal(getText(), linkPart.getText()) && equal(getTitle(), linkPart.getTitle());
+ }
+
}