From 02fae4d8e49b947ecc6893d8139681830d28015b Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sun, 29 Mar 2020 00:42:02 -0700 Subject: [PATCH] Added matches(). --- .../erik/mobibot/entries/EntryLink.java | 173 ++++++++++-------- 1 file changed, 93 insertions(+), 80 deletions(-) diff --git a/src/main/java/net/thauvin/erik/mobibot/entries/EntryLink.java b/src/main/java/net/thauvin/erik/mobibot/entries/EntryLink.java index 0365ae4..6e95c0c 100644 --- a/src/main/java/net/thauvin/erik/mobibot/entries/EntryLink.java +++ b/src/main/java/net/thauvin/erik/mobibot/entries/EntryLink.java @@ -36,6 +36,7 @@ import com.rometools.rome.feed.synd.SyndCategory; import com.rometools.rome.feed.synd.SyndCategoryImpl; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import net.thauvin.erik.mobibot.Constants; +import org.apache.commons.lang3.StringUtils; import java.io.Serializable; import java.util.Calendar; @@ -161,16 +162,6 @@ public class EntryLink implements Serializable { return channel; } - /** - * Sets the channel. - * - * @param channel The channel. - */ - @SuppressWarnings("UnusedDeclaration") - public final void setChannel(final String channel) { - this.channel = channel; - } - /** * Returns a comment. * @@ -217,15 +208,6 @@ public class EntryLink implements Serializable { return link; } - /** - * Sets the comment's link. - * - * @param link The new link. - */ - public final void setLink(final String link) { - this.link = link; - } - /** * Returns the comment's author login. * @@ -235,16 +217,6 @@ public class EntryLink implements Serializable { return login; } - /** - * Sets the comment's author login. - * - * @param login The new login. - */ - @SuppressWarnings("UnusedDeclaration") - public final void setLogin(final String login) { - this.login = login; - } - /** * Returns the comment's author nickname. * @@ -254,15 +226,6 @@ public class EntryLink implements Serializable { return nick; } - /** - * Sets the comment's author nickname. - * - * @param nick The new nickname. - */ - public final void setNick(final String nick) { - this.nick = nick; - } - /** * Returns the tags formatted for pinboard.in * @@ -288,6 +251,96 @@ public class EntryLink implements Serializable { return tags; } + /** + * Returns the comment's title. + * + * @return The title. + */ + public final String getTitle() { + return title; + } + + /** + * Returns true if the entry has comments. + * + * @return true if there are comments, false otherwise. + */ + public final boolean hasComments() { + return !comments.isEmpty(); + } + + /** + * Returns true if the entry has tags. + * + * @return true if there are tags, false otherwise. + */ + public final boolean hasTags() { + return !tags.isEmpty(); + } + + /** + * Returns true if a string is contained in the link, title, or nick. + * + * @param match The string to match. + * @return {@code true} if matched, {@code false} otherwise. + */ + public Boolean matches(final String match) { + return (StringUtils.containsIgnoreCase(link, match) + || StringUtils.containsIgnoreCase(title, match) + || StringUtils.containsIgnoreCase(nick, match)); + } + + /** + * Sets the channel. + * + * @param channel The channel. + */ + @SuppressWarnings("UnusedDeclaration") + public final void setChannel(final String channel) { + this.channel = channel; + } + + /** + * /** Sets a comment. + * + * @param index The comment's index. + * @param comment The actual comment. + * @param nick The nickname of the author of the comment. + */ + public final void setComment(final int index, final String comment, final String nick) { + if (index < comments.size()) { + comments.set(index, new EntryComment(comment, nick)); + } + } + + /** + * Sets the comment's link. + * + * @param link The new link. + */ + public final void setLink(final String link) { + this.link = link; + } + + /** + * Sets the comment's author login. + * + * @param login The new login. + */ + @SuppressWarnings("UnusedDeclaration") + public final void setLogin(final String login) { + this.login = login; + } + + /** + * Sets the comment's author nickname. + * + * @param nick The new nickname. + */ + public final void setNick(final String nick) { + this.nick = nick; + } + /** * Sets the tags. * @@ -342,15 +395,6 @@ public class EntryLink implements Serializable { this.tags.addAll(tags); } - /** - * Returns the comment's title. - * - * @return The title. - */ - public final String getTitle() { - return title; - } - /** * Sets the comment's title. * @@ -360,37 +404,6 @@ public class EntryLink implements Serializable { this.title = title; } - /** - * Returns true if the entry has comments. - * - * @return true if there are comments, false otherwise. - */ - public final boolean hasComments() { - return (!comments.isEmpty()); - } - - /** - * Returns true if the entry has tags. - * - * @return true if there are tags, false otherwise. - */ - public final boolean hasTags() { - return (!tags.isEmpty()); - } - - /** - * /** Sets a comment. - * - * @param index The comment's index. - * @param comment The actual comment. - * @param nick The nickname of the author of the comment. - */ - public final void setComment(final int index, final String comment, final String nick) { - if (index < comments.size()) { - comments.set(index, new EntryComment(comment, nick)); - } - } - /** * Returns a string representation of the object. * @@ -400,7 +413,7 @@ public class EntryLink implements Serializable { public final String toString() { return super.toString() + "[ channel -> '" + channel + '\'' + ", comments -> " + comments + ", date -> " + date - + ", link -> '" + link + '\'' + ", login -> '" + login + '\'' + ", nick -> '" + nick + '\'' - + ", tags -> " + tags + ", title -> '" + title + '\'' + " ]"; + + ", link -> '" + link + '\'' + ", login -> '" + login + '\'' + ", nick -> '" + nick + '\'' + + ", tags -> " + tags + ", title -> '" + title + '\'' + " ]"; } }