}
dependencies {
- implementation group: "com.google.guava", name: "guava", version: "14.0-rc1"
implementation group: "log4j", name: "log4j", version: "1.2.17"
implementation group: "org.apache.httpcomponents", name: "httpclient", version: "4.4"
implementation group: "org.jsoup", name: "jsoup", version: "1.16.1"
package net.pterodactylus.rhynodge.filters;
-import static com.google.common.base.Preconditions.checkState;
import static java.util.Arrays.asList;
+import static net.pterodactylus.rhynodge.utils.Preconditions.checkState;
import java.util.List;
package net.pterodactylus.rhynodge.filters;
-import static com.google.common.base.Preconditions.checkArgument;
-
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Collections;
import org.jsoup.nodes.Document;
import org.jspecify.annotations.NonNull;
+import static net.pterodactylus.rhynodge.utils.Preconditions.checkArgument;
+
/**
* {@link Filter} implementation that can extract {@link ComicState}s from
* {@link HtmlState}s.
package net.pterodactylus.rhynodge.filters;
-import static com.google.common.base.Preconditions.checkState;
-
import static java.util.Arrays.asList;
import static java.util.Optional.empty;
import static java.util.Optional.of;
import org.apache.log4j.Logger;
import org.jspecify.annotations.NonNull;
+import static net.pterodactylus.rhynodge.utils.Preconditions.checkState;
+
/**
* {@link Filter} implementation that extracts {@link Episode} information from
* the {@link TorrentFile}s contained in a {@link TorrentState}.
package net.pterodactylus.rhynodge.filters;
-import static com.google.common.base.Preconditions.*;
-
import java.util.Optional;
import net.pterodactylus.rhynodge.Filter;
import net.pterodactylus.rhynodge.State;
import org.jsoup.nodes.Document;
import org.jspecify.annotations.NonNull;
+import static net.pterodactylus.rhynodge.utils.Preconditions.checkArgument;
+
/**
* {@link Filter} implementation that extracts a URL from an {@link HtmlState}.
*
package net.pterodactylus.rhynodge.filters;
-import static com.google.common.base.Preconditions.checkState;
-
import net.pterodactylus.rhynodge.Filter;
import net.pterodactylus.rhynodge.State;
import net.pterodactylus.rhynodge.states.FailedState;
import org.jsoup.nodes.Document;
import org.jspecify.annotations.NonNull;
+import static net.pterodactylus.rhynodge.utils.Preconditions.checkState;
+
/**
* {@link Filter} that converts a {@link HttpState} into an {@link HtmlState}.
*
package net.pterodactylus.rhynodge.filters;
-import static com.google.common.base.Preconditions.*;
-
import net.pterodactylus.rhynodge.Filter;
import net.pterodactylus.rhynodge.State;
import net.pterodactylus.rhynodge.queries.HttpQuery;
import org.jspecify.annotations.NonNull;
+import static net.pterodactylus.rhynodge.utils.Preconditions.checkArgument;
+
/**
* {@link Filter} implementation that uses the {@link StringState#value() value}
* of a {@link StringState} as a URL for {@link HttpQuery}, turning it into an
package net.pterodactylus.rhynodge.filters;
-import static com.google.common.base.Preconditions.checkState;
-
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import org.jsoup.select.Elements;
import org.jspecify.annotations.NonNull;
+import static net.pterodactylus.rhynodge.utils.Preconditions.checkState;
+
/**
* {@link Filter} implementation that parses a {@link TorrentState} from an
* {@link HtmlState} which was generated by a {@link HttpQuery} to
import net.pterodactylus.rhynodge.states.ComicState.Comic;
import org.jspecify.annotations.NonNull;
-import static com.google.common.base.Preconditions.checkArgument;
+import static net.pterodactylus.rhynodge.utils.Preconditions.checkArgument;
/**
* {@link Merger} implementation that merger two {@link ComicState}s.
import net.pterodactylus.rhynodge.states.TorrentState.TorrentFile;
import org.jspecify.annotations.NonNull;
-import static com.google.common.base.Preconditions.checkState;
+import static net.pterodactylus.rhynodge.utils.Preconditions.checkState;
import static java.util.function.Function.identity;
import static java.util.stream.Collectors.toMap;
import net.pterodactylus.rhynodge.states.TorrentState.TorrentFile;
import org.jspecify.annotations.NonNull;
-import static com.google.common.base.Preconditions.checkState;
+import static net.pterodactylus.rhynodge.utils.Preconditions.checkState;
/**
* {@link Merger} implementation that merges two {@link TorrentState}s, taking
--- /dev/null
+@file:JvmName("Preconditions")
+
+package net.pterodactylus.rhynodge.utils
+
+import java.lang.String.format
+
+/**
+ * Checks that the given [state] is `true` and throws an
+ * [IllegalStateException] if it is `false`.
+ *
+ * @param[state] The state to check
+ * @param[message] The message for the thrown exception; [String.format]
+ * with the given [parameters] will be used as message for the exception
+ * @param[parameters] The parameters for the exception
+ */
+fun checkState(state: Boolean, message: String, vararg parameters: Any?) {
+ if (!state) {
+ throw IllegalStateException(format(message, *parameters))
+ }
+}
+
+/**
+ * Checks that the given [state] is `true` and throws an
+ * [IllegalArgumentException] if it is `false`.
+ *
+ * @param[state] The state to check
+ * @param[message] The message for the thrown exception; [String.format]
+ * with the given [parameters] will be used as message for the exception
+ * @param[parameters] The parameters for the exception
+ */
+fun checkArgument(state: Boolean, message: String, vararg parameters: Any?) {
+ if (!state) {
+ throw IllegalArgumentException(format(message, *parameters))
+ }
+}