2 * Sone - LinkPart.java - Copyright © 2011–2013 David Roden
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package net.pterodactylus.sone.text;
20 import static com.google.common.base.Objects.equal;
23 * {@link Part} implementation that can hold a link. A link contains of three
24 * attributes: the link itself, the text that is shown instead of the link, and
25 * an explanatory text that can be displayed e.g. as a tooltip.
27 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
29 public class LinkPart implements Part {
31 /** The link of this part. */
32 private final String link;
34 /** The text of this part. */
35 private final String text;
37 /** The title of this part. */
38 private final String title;
41 * Creates a new link part.
44 * The link of the link part
46 * The text of the link part
48 public LinkPart(String link, String text) {
49 this(link, text, text);
53 * Creates a new link part.
56 * The link of the link part
58 * The text of the link part
60 * The title of the link part
62 public LinkPart(String link, String text, String title) {
73 * Returns the link of this part.
75 * @return The link of this part
77 public String getLink() {
82 * Returns the title of this part.
84 * @return The title of this part
86 public String getTitle() {
95 public String getText() {
100 public int hashCode() {
101 return getLink().hashCode() ^ (getTitle().hashCode() << 16) ^ getText().hashCode();
105 public boolean equals(Object object) {
106 if (!(object instanceof LinkPart)) {
109 LinkPart linkPart = (LinkPart) object;
110 return equal(getLink(), linkPart.getLink()) && equal(getText(), linkPart.getText()) && equal(getTitle(), linkPart.getTitle());