UriBuilder implements IBuilder<URI> { @Nullable public static String[] getPathArray(@NonNull URI uri) { String path = uri.getRawPath(); return path != null && !path.isEmpty() ? splitToArray(path.subSequence(1, path.length())) : null; } UriBuilder(@NonNull String scheme, @NonNull String host); @NonNull UriBuilder reset(); @NonNull UriBuilder path(@Nullable String... path); @NonNull UriBuilder query(@Nullable SortedMap<String, String> query); @NonNull UriBuilder fragment(@Nullable SortedMap<String, String> fragment); @NonNull String buildString(); @Override URI build(); @Nullable static String[] getPathArray(@NonNull URI uri); @Nullable static String[] getPathArray(@NonNull URI uri, int expectedSize); @Nullable static Map<String, String> getQueryMap(@NonNull URI uri); @Nullable static Map<String, String> getFragmentMap(@NonNull URI uri);  }
@Test public void testGetPathArray() { Assertions.assertThat(new UriBuilder(scheme, host).build()).satisfies(o -> { Assertions.assertThat(UriBuilder.getPathArray(o, 0)).isNull(); Assertions.assertThat(UriBuilder.getPathArray(o, 1)).isNull(); }); Assertions.assertThat(new UriBuilder(scheme, host).path(path).build()).satisfies(o -> { Assertions.assertThat(UriBuilder.getPathArray(o, 0)).isNull(); Assertions.assertThat(UriBuilder.getPathArray(o, 1)).isNull(); Assertions.assertThat(UriBuilder.getPathArray(o, 2)).containsExactly(path); Assertions.assertThat(UriBuilder.getPathArray(o, 3)).isNull(); }); }