Added matches().

This commit is contained in:
Erik C. Thauvin 2020-03-29 00:42:02 -07:00
parent 4aeb17ecef
commit 02fae4d8e4

View file

@ -36,6 +36,7 @@ import com.rometools.rome.feed.synd.SyndCategory;
import com.rometools.rome.feed.synd.SyndCategoryImpl; import com.rometools.rome.feed.synd.SyndCategoryImpl;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import net.thauvin.erik.mobibot.Constants; import net.thauvin.erik.mobibot.Constants;
import org.apache.commons.lang3.StringUtils;
import java.io.Serializable; import java.io.Serializable;
import java.util.Calendar; import java.util.Calendar;
@ -161,16 +162,6 @@ public class EntryLink implements Serializable {
return channel; return channel;
} }
/**
* Sets the channel.
*
* @param channel The channel.
*/
@SuppressWarnings("UnusedDeclaration")
public final void setChannel(final String channel) {
this.channel = channel;
}
/** /**
* Returns a comment. * Returns a comment.
* *
@ -217,15 +208,6 @@ public class EntryLink implements Serializable {
return link; 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. * Returns the comment's author login.
* *
@ -235,16 +217,6 @@ public class EntryLink implements Serializable {
return login; 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. * Returns the comment's author nickname.
* *
@ -254,15 +226,6 @@ public class EntryLink implements Serializable {
return nick; 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 * Returns the tags formatted for pinboard.in
* *
@ -288,6 +251,96 @@ public class EntryLink implements Serializable {
return tags; 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. * Sets the tags.
* *
@ -342,15 +395,6 @@ public class EntryLink implements Serializable {
this.tags.addAll(tags); this.tags.addAll(tags);
} }
/**
* Returns the comment's title.
*
* @return The title.
*/
public final String getTitle() {
return title;
}
/** /**
* Sets the comment's title. * Sets the comment's title.
* *
@ -360,37 +404,6 @@ public class EntryLink implements Serializable {
this.title = title; 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. * Returns a string representation of the object.
* *
@ -400,7 +413,7 @@ public class EntryLink implements Serializable {
public final String toString() { public final String toString() {
return super.toString() + "[ channel -> '" + channel + '\'' + ", comments -> " + comments + ", date -> " + date return super.toString() + "[ channel -> '" + channel + '\'' + ", comments -> " + comments + ", date -> " + date
+ ", link -> '" + link + '\'' + ", login -> '" + login + '\'' + ", nick -> '" + nick + '\'' + ", link -> '" + link + '\'' + ", login -> '" + login + '\'' + ", nick -> '" + nick + '\''
+ ", tags -> " + tags + ", title -> '" + title + '\'' + " ]"; + ", tags -> " + tags + ", title -> '" + title + '\'' + " ]";
} }
} }