|
7 | 7 | import java.io.InputStreamReader; |
8 | 8 | import java.net.URLEncoder; |
9 | 9 | import java.util.List; |
| 10 | +import java.util.stream.Collectors; |
10 | 11 | import org.apache.http.client.methods.CloseableHttpResponse; |
11 | 12 | import org.apache.http.client.methods.HttpGet; |
12 | 13 | import org.apache.http.impl.client.CloseableHttpClient; |
@@ -55,18 +56,19 @@ private static SearchResult select(String query, int start, int count) throws IO |
55 | 56 | String finalQuery; |
56 | 57 | if (parts.length >= 3) { |
57 | 58 | // Exact group/artifact match for retrieving versions |
58 | | - finalQuery = "g:%s AND a:%s".formatted(parts[0], parts[1]); |
| 59 | + finalQuery = String.format("g:%s AND a:%s", parts[0], parts[1]); |
59 | 60 | } else if (parts.length == 2) { |
60 | 61 | // Partial group/artifact match, we will filter the results |
61 | 62 | // to remove those that match an inverted artifact/group |
62 | | - finalQuery = "%s AND %s".formatted(parts[0], parts[1]); |
| 63 | + finalQuery = String.format("%s AND %s", parts[0], parts[1]); |
63 | 64 | } else { |
64 | 65 | // Simple partial match |
65 | 66 | finalQuery = query; |
66 | 67 | } |
67 | 68 | String searchUrl = |
68 | | - "https://search.maven.org/solrsearch/select?start=%d&rows=%d&q=%s" |
69 | | - .formatted(start, count, URLEncoder.encode(finalQuery, "UTF-8")); |
| 69 | + String.format( |
| 70 | + "https://search.maven.org/solrsearch/select?start=%d&rows=%d&q=%s", |
| 71 | + start, count, URLEncoder.encode(finalQuery, "UTF-8")); |
70 | 72 | if (parts.length >= 3) { |
71 | 73 | searchUrl += "&core=gav"; |
72 | 74 | } |
@@ -100,7 +102,7 @@ private static SearchResult select(String query, int start, int count) throws IO |
100 | 102 | d.a, |
101 | 103 | "", |
102 | 104 | d.v != null ? d.v : d.latestVersion)) |
103 | | - .toList(); |
| 105 | + .collect(Collectors.toList()); |
104 | 106 | return new SearchResult(artifacts, query, start, count, result.response.numFound); |
105 | 107 | } |
106 | 108 | } |
|
0 commit comments