X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ftext%2FLinkPart.java;h=a3f67ada587eb5de8910bc11cb8786b18af4d9b6;hb=541f49177de5f63a97d94fe74ffb60badbf5d4c9;hp=1b47080da7947b420324394b4afa54b34c477d21;hpb=480691a26222e035e53bda56029524e160fdf898;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/text/LinkPart.java b/src/main/java/net/pterodactylus/sone/text/LinkPart.java index 1b47080..a3f67ad 100644 --- a/src/main/java/net/pterodactylus/sone/text/LinkPart.java +++ b/src/main/java/net/pterodactylus/sone/text/LinkPart.java @@ -1,5 +1,5 @@ /* - * Sone - LinkPart.java - Copyright © 2011–2012 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 @@ -17,6 +17,8 @@ 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 @@ -77,15 +79,6 @@ public class LinkPart implements Part { } /** - * 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 @@ -94,4 +87,27 @@ public class LinkPart implements Part { return title; } + // + // 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()); + } + }