@Test public void testBuildPath() { Assertions.assertThat(UriBuilder.uri("/base", "/foo", "bar")).isEqualTo("/base/foo/bar"); Assertions.assertThat(UriBuilder.uri("/base/", "/foo/", "bar")).isEqualTo("/base/foo/bar"); Assertions.assertThat(UriBuilder.uri("http: }
static String uri(final String... paths) { StringBuilder sb = new StringBuilder(); boolean firstPath = true; for (String s : paths) { if (s == null || s.isEmpty()) { continue; } if (!s.startsWith("/") && !firstPath) { sb.append("/"); } sb.append(stripLeadingSlash(s)); firstPath = false; } return sb.toString(); }
UriBuilder { static String uri(final String... paths) { StringBuilder sb = new StringBuilder(); boolean firstPath = true; for (String s : paths) { if (s == null || s.isEmpty()) { continue; } if (!s.startsWith("/") && !firstPath) { sb.append("/"); } sb.append(stripLeadingSlash(s)); firstPath = false; } return sb.toString(); } }
UriBuilder { static String uri(final String... paths) { StringBuilder sb = new StringBuilder(); boolean firstPath = true; for (String s : paths) { if (s == null || s.isEmpty()) { continue; } if (!s.startsWith("/") && !firstPath) { sb.append("/"); } sb.append(stripLeadingSlash(s)); firstPath = false; } return sb.toString(); } private  UriBuilder(); }
UriBuilder { static String uri(final String... paths) { StringBuilder sb = new StringBuilder(); boolean firstPath = true; for (String s : paths) { if (s == null || s.isEmpty()) { continue; } if (!s.startsWith("/") && !firstPath) { sb.append("/"); } sb.append(stripLeadingSlash(s)); firstPath = false; } return sb.toString(); } private  UriBuilder();  }
UriBuilder { static String uri(final String... paths) { StringBuilder sb = new StringBuilder(); boolean firstPath = true; for (String s : paths) { if (s == null || s.isEmpty()) { continue; } if (!s.startsWith("/") && !firstPath) { sb.append("/"); } sb.append(stripLeadingSlash(s)); firstPath = false; } return sb.toString(); } private  UriBuilder();   }