From: David ‘Bombe’ Roden Date: Tue, 12 Jul 2011 04:54:53 +0000 (+0200) Subject: Override hashCode() and equals() in Phrase. X-Git-Tag: 0.6.6^2~19 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=97bb7b5c2f8fe5b55ce843e13e27d194d79ab047;p=Sone.git Override hashCode() and equals() in Phrase. --- diff --git a/src/main/java/net/pterodactylus/sone/web/SearchPage.java b/src/main/java/net/pterodactylus/sone/web/SearchPage.java index 2a1c1b0..c1b7c3c 100644 --- a/src/main/java/net/pterodactylus/sone/web/SearchPage.java +++ b/src/main/java/net/pterodactylus/sone/web/SearchPage.java @@ -413,6 +413,30 @@ public class SearchPage extends SoneTemplatePage { return optionality; } + // + // OBJECT METHODS + // + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + return phrase.hashCode() ^ ((optionality == Optionality.FORBIDDEN) ? (0xaaaaaaaa) : ((optionality == Optionality.REQUIRED) ? 0x55555555 : 0)); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object object) { + if (!(object instanceof Phrase)) { + return false; + } + Phrase phrase = (Phrase) object; + return (this.optionality == phrase.optionality) && this.phrase.equals(phrase.phrase); + } + } /**