public static String addQuery(String url, String... parameters) {
        if (parameters.length % 2 != 0)
            throw new IllegalArgumentException("Expected an even number of parameters.");

        var result = new StringBuilder(url);
        var printedParams = 0;
        for (var i = 0; i < parameters.length; i += 2) {
            var key = parameters[i];
            var value = parameters[i + 1];
            if (key == null)
                throw new NullPointerException("Parameter key must not be null");
            if (value != null) {
                if (printedParams == 0)
                    result.append('?');
                else
                    result.append('&');
                result.append(key).append('=').append(UriUtils.encodeQueryParam(value, StandardCharsets.UTF_8));
                printedParams++;
            }
        }
        return result.toString();
    }
@Test
    public void testQuery() throws Exception {
        var url = "http://localhost/api/foo";
        assertThat(UrlUtil.addQuery(url, "a", "1", "b", null, "c", "b\ta/r"))
                .isEqualTo("http://localhost/api/foo?a=1&c=b%09a/r");
    }