Commit 5db8b32b authored by Florian Schäfer's avatar Florian Schäfer

Remove ApiUrl.url() method with multiple arguments

Wasn't used often and didn't have a big performance advantage (if any) over normal concatenation.
parent 0f74065f
Pipeline #27251108 passed with stages
in 16 minutes and 11 seconds
......@@ -14,28 +14,6 @@ public class ApiUrl {
// Private constructor to avoid instantiation
* Concatenates all parameters (nulls are treated like empty strings) to a single string and passes that to
* {@link #url(String)}.
* @param part1
* the first part of the URL
* @param part2
* the second part of the URL
* @param moreParts
* the rest of the parts of the URL
* @return the URL that is returned from {@link #url(String)} when passing it the concatenated parts
* @throws IllegalArgumentException
* when the returned URL would be malformed
public static URL url(final String part1, final String part2, final String... moreParts) {
return url(
Stream.concat(Stream.of(part1, part2),
* The same as {@link URL#URL(String)}, except that any {@link MalformedURLException} will be wrapped inside
* an {@link IllegalArgumentException}, which is unchecked.
......@@ -51,7 +29,7 @@ public class ApiUrl {
try {
return new URL(url);
} catch (MalformedURLException e) {
final String message = "The wikipedia plugin tries to construct a malformed URL!";
final String message = String.format("The wikipedia plugin tries to construct a malformed URL!: %s", url);
Logging.log(Logging.LEVEL_ERROR, message, e);
throw new IllegalArgumentException(message, e);
......@@ -20,7 +20,7 @@ public class WikipediaActionApiQuery<T> extends ApiQuery<T> {
private final String queryString;
private WikipediaActionApiQuery(final IWikipediaSite site, final String queryString, SerializationSchema<T> schema) {
super(ApiUrl.url(site.getSite().getUrl(), "/w/api.php"), schema);
super(ApiUrl.url(site.getSite().getUrl() + "/w/api.php"), schema);
this.queryString = Objects.requireNonNull(queryString);
......@@ -14,15 +14,10 @@ public class ApiUrlTest {
@Test(expected = IllegalArgumentException.class)
public void testMalformedMultipartUrl() {
ApiUrl.url("malformed", "Multipart", "U", "R", "L");
public void testUrl() throws MalformedURLException {
assertEquals(new URL(""), ApiUrl.url(""));
assertEquals(new URL(""), ApiUrl.url("", "abc"));
assertEquals(new URL(""), ApiUrl.url("", "abc/", "def/", "ghi/", "jkl/", "mno"));
assertEquals(new URL(""), ApiUrl.url(""));
assertEquals(new URL(""), ApiUrl.url(""));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment