public static String joinPaths(final String... paths) {
        if (paths == null || paths.length == 0) {
            return "";
        }

        final StringBuilder joined = new StringBuilder();

        boolean addedLast = false;
        for (int i = paths.length - 1; i >= 0; i--) {
            String path = paths[i];
            if (ObjectHelper.isNotEmpty(path)) {
                if (addedLast) {
                    path = stripSuffix(path, "/");
                }

                addedLast = true;

                if (path.charAt(0) == '/') {
                    joined.insert(0, path);
                } else {
                    if (i > 0) {
                        joined.insert(0, '/').insert(1, path);
                    } else {
                        joined.insert(0, path);
                    }
                }
            }
        }

        return joined.toString();
    }
@Test
    public void shouldJoinPaths() {
        assertThat(URISupport.joinPaths(null, null)).isEmpty();
        assertThat(URISupport.joinPaths("", null)).isEmpty();
        assertThat(URISupport.joinPaths(null, "")).isEmpty();
        assertThat(URISupport.joinPaths("", "")).isEmpty();
        assertThat(URISupport.joinPaths("a", "")).isEqualTo("a");
        assertThat(URISupport.joinPaths("a", "b")).isEqualTo("a/b");
        assertThat(URISupport.joinPaths("/a", "b")).isEqualTo("/a/b");
        assertThat(URISupport.joinPaths("/a", "b/")).isEqualTo("/a/b/");
        assertThat(URISupport.joinPaths("/a/", "b/")).isEqualTo("/a/b/");
        assertThat(URISupport.joinPaths("/a/", "/b/")).isEqualTo("/a/b/");
        assertThat(URISupport.joinPaths("a", "b", "c")).isEqualTo("a/b/c");
        assertThat(URISupport.joinPaths("a", null, "c")).isEqualTo("a/c");
        assertThat(URISupport.joinPaths("/a/", "/b", "c/", "/d/")).isEqualTo("/a/b/c/d/");
        assertThat(URISupport.joinPaths("/a/", "/b", "c/", null)).isEqualTo("/a/b/c/");
        assertThat(URISupport.joinPaths("/a/", null, null, null)).isEqualTo("/a/");
        assertThat(URISupport.joinPaths("a/", "/b", null, null)).isEqualTo("a/b");
    }