From: David ‘Bombe’ Roden Date: Sat, 28 May 2016 12:52:39 +0000 (+0200) Subject: Annotate Filter interface with @NotNull X-Git-Tag: v2~126 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=d4fe0c7f56a77104924bf50cbfeb6775cd12dc25;p=rhynodge.git Annotate Filter interface with @NotNull --- diff --git a/src/main/java/net/pterodactylus/rhynodge/Filter.java b/src/main/java/net/pterodactylus/rhynodge/Filter.java index b175b48..1906afa 100644 --- a/src/main/java/net/pterodactylus/rhynodge/Filter.java +++ b/src/main/java/net/pterodactylus/rhynodge/Filter.java @@ -17,6 +17,8 @@ package net.pterodactylus.rhynodge; +import org.jetbrains.annotations.NotNull; + /** * Defines a filter that runs between {@link Query}s and {@link Trigger}s and * can be used to convert a {@link State} into another {@link State}. This can @@ -38,6 +40,7 @@ public interface Filter { * The state to convert * @return The new state */ - State filter(State state); + @NotNull + State filter(@NotNull State state); } diff --git a/src/main/java/net/pterodactylus/rhynodge/filters/BlacklistFilter.java b/src/main/java/net/pterodactylus/rhynodge/filters/BlacklistFilter.java index 8374ac0..5bac2a0 100644 --- a/src/main/java/net/pterodactylus/rhynodge/filters/BlacklistFilter.java +++ b/src/main/java/net/pterodactylus/rhynodge/filters/BlacklistFilter.java @@ -30,6 +30,7 @@ import net.pterodactylus.rhynodge.states.TorrentState; import net.pterodactylus.rhynodge.states.TorrentState.TorrentFile; import com.google.common.base.Predicate; +import org.jetbrains.annotations.NotNull; /** * Filter for {@link TorrentState}s that removes all {@link TorrentFile}s whose @@ -45,8 +46,9 @@ public class BlacklistFilter implements Filter { this.filterWords = filterWords; } + @NotNull @Override - public State filter(State state) { + public State filter(@NotNull State state) { if (!state.success()) { return FailedState.from(state); } diff --git a/src/main/java/net/pterodactylus/rhynodge/filters/ComicSiteFilter.java b/src/main/java/net/pterodactylus/rhynodge/filters/ComicSiteFilter.java index 39da74d..19286a6 100644 --- a/src/main/java/net/pterodactylus/rhynodge/filters/ComicSiteFilter.java +++ b/src/main/java/net/pterodactylus/rhynodge/filters/ComicSiteFilter.java @@ -32,6 +32,7 @@ import net.pterodactylus.rhynodge.states.FailedState; import net.pterodactylus.rhynodge.states.HtmlState; import com.google.common.base.Optional; +import org.jetbrains.annotations.NotNull; import org.jsoup.nodes.Document; /** @@ -42,8 +43,9 @@ import org.jsoup.nodes.Document; */ public abstract class ComicSiteFilter implements Filter { + @NotNull @Override - public State filter(State state) { + public State filter(@NotNull State state) { checkArgument(state instanceof HtmlState, "state must be an HTML state"); /* initialize states: */ diff --git a/src/main/java/net/pterodactylus/rhynodge/filters/EpisodeFilter.java b/src/main/java/net/pterodactylus/rhynodge/filters/EpisodeFilter.java index 9ba7cec..6aa3e1f 100644 --- a/src/main/java/net/pterodactylus/rhynodge/filters/EpisodeFilter.java +++ b/src/main/java/net/pterodactylus/rhynodge/filters/EpisodeFilter.java @@ -39,6 +39,7 @@ import com.google.common.base.Optional; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; /** * {@link Filter} implementation that extracts {@link Episode} information from @@ -60,8 +61,9 @@ public class EpisodeFilter implements Filter { /** * {@inheritDoc} */ + @NotNull @Override - public State filter(State state) { + public State filter(@NotNull State state) { if (!state.success()) { return FailedState.from(state); } diff --git a/src/main/java/net/pterodactylus/rhynodge/filters/ExtractUrlFilter.java b/src/main/java/net/pterodactylus/rhynodge/filters/ExtractUrlFilter.java index b075686..78c589e 100644 --- a/src/main/java/net/pterodactylus/rhynodge/filters/ExtractUrlFilter.java +++ b/src/main/java/net/pterodactylus/rhynodge/filters/ExtractUrlFilter.java @@ -26,6 +26,7 @@ import net.pterodactylus.rhynodge.states.HtmlState; import net.pterodactylus.rhynodge.states.StringState; import com.google.common.base.Optional; +import org.jetbrains.annotations.NotNull; import org.jsoup.nodes.Document; /** @@ -35,8 +36,9 @@ import org.jsoup.nodes.Document; */ public abstract class ExtractUrlFilter implements Filter { + @NotNull @Override - public State filter(State state) { + public State filter(@NotNull State state) { checkArgument(state instanceof HtmlState, "state must be an HTML state"); HtmlState htmlState = (HtmlState) state; diff --git a/src/main/java/net/pterodactylus/rhynodge/filters/HtmlFilter.java b/src/main/java/net/pterodactylus/rhynodge/filters/HtmlFilter.java index 0403b6d..788203c 100644 --- a/src/main/java/net/pterodactylus/rhynodge/filters/HtmlFilter.java +++ b/src/main/java/net/pterodactylus/rhynodge/filters/HtmlFilter.java @@ -26,6 +26,7 @@ import net.pterodactylus.rhynodge.states.HtmlState; import net.pterodactylus.rhynodge.states.HttpState; import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; @@ -41,8 +42,9 @@ public class HtmlFilter implements Filter { /** * {@inheritDoc} */ + @NotNull @Override - public State filter(State state) { + public State filter(@NotNull State state) { if (!state.success()) { return FailedState.from(state); } diff --git a/src/main/java/net/pterodactylus/rhynodge/filters/HttpQueryFilter.java b/src/main/java/net/pterodactylus/rhynodge/filters/HttpQueryFilter.java index 2600288..00533de 100644 --- a/src/main/java/net/pterodactylus/rhynodge/filters/HttpQueryFilter.java +++ b/src/main/java/net/pterodactylus/rhynodge/filters/HttpQueryFilter.java @@ -25,6 +25,8 @@ import net.pterodactylus.rhynodge.queries.HttpQuery; import net.pterodactylus.rhynodge.states.HttpState; import net.pterodactylus.rhynodge.states.StringState; +import org.jetbrains.annotations.NotNull; + /** * {@link Filter} implementation that uses the {@link StringState#value() value} * of a {@link StringState} as a URL for {@link HttpQuery}, turning it into an @@ -34,8 +36,9 @@ import net.pterodactylus.rhynodge.states.StringState; */ public class HttpQueryFilter implements Filter { + @NotNull @Override - public State filter(State state) { + public State filter(@NotNull State state) { checkArgument(state instanceof StringState, "state must be a String state"); StringState stringState = (StringState) state; diff --git a/src/main/java/net/pterodactylus/rhynodge/filters/TorrentSiteFilter.java b/src/main/java/net/pterodactylus/rhynodge/filters/TorrentSiteFilter.java index b3b5691..cf1a8b5 100644 --- a/src/main/java/net/pterodactylus/rhynodge/filters/TorrentSiteFilter.java +++ b/src/main/java/net/pterodactylus/rhynodge/filters/TorrentSiteFilter.java @@ -32,6 +32,7 @@ import net.pterodactylus.rhynodge.states.HtmlState; import net.pterodactylus.rhynodge.states.TorrentState; import net.pterodactylus.rhynodge.states.TorrentState.TorrentFile; +import org.jetbrains.annotations.NotNull; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; @@ -48,8 +49,9 @@ public abstract class TorrentSiteFilter implements Filter { /** * {@inheritDoc} */ + @NotNull @Override - public State filter(State state) { + public State filter(@NotNull State state) { if (!state.success()) { return FailedState.from(state); } diff --git a/src/main/java/net/pterodactylus/rhynodge/filters/webpages/savoy/SavoyTicketsFilter.java b/src/main/java/net/pterodactylus/rhynodge/filters/webpages/savoy/SavoyTicketsFilter.java index 1f9736d..14c6c22 100644 --- a/src/main/java/net/pterodactylus/rhynodge/filters/webpages/savoy/SavoyTicketsFilter.java +++ b/src/main/java/net/pterodactylus/rhynodge/filters/webpages/savoy/SavoyTicketsFilter.java @@ -25,6 +25,7 @@ import net.pterodactylus.rhynodge.filters.webpages.savoy.TicketLink; import net.pterodactylus.rhynodge.states.HtmlState; import net.pterodactylus.rhynodge.states.OutputState; +import org.jetbrains.annotations.NotNull; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.nodes.Node; @@ -42,8 +43,9 @@ public class SavoyTicketsFilter implements Filter { private DateTimeFormatter timeFormatter = ofPattern("HH:mm"); private DateTimeFormatter dateTimeFormatter = ofPattern("dd.MM.uuuu, HH:mm"); + @NotNull @Override - public State filter(State state) { + public State filter(@NotNull State state) { checkArgument(state instanceof HtmlState, "state must be HTML"); HtmlState htmlState = (HtmlState) state; diff --git a/src/main/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/WetterComFilter.kt b/src/main/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/WetterComFilter.kt index bf6f97e..04f38fa 100644 --- a/src/main/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/WetterComFilter.kt +++ b/src/main/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/WetterComFilter.kt @@ -20,8 +20,8 @@ class WetterComFilter : Filter { private val dateTimeFormatter = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm") - override fun filter(state: State?): State { - if (state?.success()?.not() ?: true) { + override fun filter(state: State): State { + if (state.success().not()) { return FailedState.from(state) } if (state !is HtmlState) {