From 1a7e8c88cc885e56cc42eb32bec93d25d37b4437 Mon Sep 17 00:00:00 2001 From: Louis Vallat Date: Tue, 23 Apr 2019 12:15:51 +0200 Subject: [PATCH] added support for "isXXX" is text ? image ? link ? video ? --- .../reddit_handler/RedditPost.java | 25 +++++++++++++++++++ .../reddit_handler/RedditPostImage.java | 23 ++++++++++++++++- .../reddit_handler/RedditPostLink.java | 24 +++++++++++++++++- .../reddit_handler/RedditPostText.java | 23 ++++++++++++++++- .../reddit_handler/RedditPostVideo.java | 24 +++++++++++++++++- 5 files changed, 115 insertions(+), 4 deletions(-) diff --git a/twitter_techsupportgore_bot/src/twitter_techsupportgore_bot/reddit_handler/RedditPost.java b/twitter_techsupportgore_bot/src/twitter_techsupportgore_bot/reddit_handler/RedditPost.java index 2a33842..9a4ae6e 100644 --- a/twitter_techsupportgore_bot/src/twitter_techsupportgore_bot/reddit_handler/RedditPost.java +++ b/twitter_techsupportgore_bot/src/twitter_techsupportgore_bot/reddit_handler/RedditPost.java @@ -194,4 +194,29 @@ public abstract class RedditPost { public String getPostId() { return postId; } + + /** + * Is this post an image? + * @return if the post is an image. + */ + public abstract boolean isImage(); + + /** + * Is this post a text? + * @return if the post is a text. + */ + public abstract boolean isText(); + + /** + * Is this post a video? + * @return if the post is a video. + */ + public abstract boolean isVideo(); + + + /** + * Is this post a link? + * @return if the post is a link. + */ + public abstract boolean isLink(); } diff --git a/twitter_techsupportgore_bot/src/twitter_techsupportgore_bot/reddit_handler/RedditPostImage.java b/twitter_techsupportgore_bot/src/twitter_techsupportgore_bot/reddit_handler/RedditPostImage.java index e09d729..f25baae 100644 --- a/twitter_techsupportgore_bot/src/twitter_techsupportgore_bot/reddit_handler/RedditPostImage.java +++ b/twitter_techsupportgore_bot/src/twitter_techsupportgore_bot/reddit_handler/RedditPostImage.java @@ -22,8 +22,29 @@ package twitter_techsupportgore_bot.reddit_handler; */ public class RedditPostImage extends RedditPost { - public RedditPostImage(String id, String title, boolean quarantine, double score, String postHint, boolean crosspostable, boolean over18, String author, String permalink, boolean spoiler) { + public RedditPostImage(String id, String title, boolean quarantine, + double score, String postHint, boolean crosspostable, + boolean over18, String author, String permalink, boolean spoiler) { super(id, title, quarantine, score, postHint, crosspostable, over18, author, permalink, spoiler); } + @Override + public boolean isImage() { + return true; + } + + @Override + public boolean isText() { + return false; + } + + @Override + public boolean isVideo() { + return false; + } + + @Override + public boolean isLink() { + return false; + } } diff --git a/twitter_techsupportgore_bot/src/twitter_techsupportgore_bot/reddit_handler/RedditPostLink.java b/twitter_techsupportgore_bot/src/twitter_techsupportgore_bot/reddit_handler/RedditPostLink.java index 30c80e2..26827d4 100644 --- a/twitter_techsupportgore_bot/src/twitter_techsupportgore_bot/reddit_handler/RedditPostLink.java +++ b/twitter_techsupportgore_bot/src/twitter_techsupportgore_bot/reddit_handler/RedditPostLink.java @@ -22,8 +22,30 @@ package twitter_techsupportgore_bot.reddit_handler; */ public class RedditPostLink extends RedditPost { - public RedditPostLink(String id, String title, boolean quarantine, double score, String postHint, boolean crosspostable, boolean over18, String author, String permalink, boolean spoiler) { + public RedditPostLink(String id, String title, boolean quarantine, + double score, String postHint, boolean crosspostable, + boolean over18, String author, String permalink, boolean spoiler) { super(id, title, quarantine, score, postHint, crosspostable, over18, author, permalink, spoiler); } + + @Override + public boolean isImage() { + return false; + } + + @Override + public boolean isText() { + return false; + } + + @Override + public boolean isVideo() { + return false; + } + + @Override + public boolean isLink() { + return true; + } } diff --git a/twitter_techsupportgore_bot/src/twitter_techsupportgore_bot/reddit_handler/RedditPostText.java b/twitter_techsupportgore_bot/src/twitter_techsupportgore_bot/reddit_handler/RedditPostText.java index 0e3ffc3..0f4855a 100644 --- a/twitter_techsupportgore_bot/src/twitter_techsupportgore_bot/reddit_handler/RedditPostText.java +++ b/twitter_techsupportgore_bot/src/twitter_techsupportgore_bot/reddit_handler/RedditPostText.java @@ -22,8 +22,29 @@ package twitter_techsupportgore_bot.reddit_handler; */ public class RedditPostText extends RedditPost { - public RedditPostText(String id, String title, boolean quarantine, double score, String postHint, boolean crosspostable, boolean over18, String author, String permalink, boolean spoiler) { + public RedditPostText(String id, String title, boolean quarantine, + double score, String postHint, boolean crosspostable, + boolean over18, String author, String permalink, boolean spoiler) { super(id, title, quarantine, score, postHint, crosspostable, over18, author, permalink, spoiler); } + @Override + public boolean isImage() { + return false; + } + + @Override + public boolean isText() { + return true; + } + + @Override + public boolean isVideo() { + return false; + } + + @Override + public boolean isLink() { + return false; + } } diff --git a/twitter_techsupportgore_bot/src/twitter_techsupportgore_bot/reddit_handler/RedditPostVideo.java b/twitter_techsupportgore_bot/src/twitter_techsupportgore_bot/reddit_handler/RedditPostVideo.java index 38b30de..940312f 100644 --- a/twitter_techsupportgore_bot/src/twitter_techsupportgore_bot/reddit_handler/RedditPostVideo.java +++ b/twitter_techsupportgore_bot/src/twitter_techsupportgore_bot/reddit_handler/RedditPostVideo.java @@ -22,8 +22,30 @@ package twitter_techsupportgore_bot.reddit_handler; */ public class RedditPostVideo extends RedditPost{ - public RedditPostVideo(String id, String title, boolean quarantine, double score, String postHint, boolean crosspostable, boolean over18, String author, String permalink, boolean spoiler) { + public RedditPostVideo(String id, String title, boolean quarantine, + double score, String postHint, boolean crosspostable, + boolean over18, String author, String permalink, boolean spoiler) { super(id, title, quarantine, score, postHint, crosspostable, over18, author, permalink, spoiler); } + @Override + public boolean isImage() { + return false; + } + + @Override + public boolean isText() { + return false; + } + + @Override + public boolean isVideo() { + return true; + } + + @Override + public boolean isLink() { + return false; + } + }