@Test public void pathPartsTest() { final String INPUT_A = "/znode"; final List<String> RESULT_A = pathParts(INPUT_A); assertThat(RESULT_A.size(), is(1)); assertThat(RESULT_A.get(0), is("/znode")); final String INPUT_B = "/znode/nested"; List<String> RESULT_B = pathParts(INPUT_B); assertThat(RESULT_B.size(), is(2)); assertThat(RESULT_B.get(0), is("/znode")); assertThat(RESULT_B.get(1), is("/znode/nested")); }
static List<String> pathParts(String path) { String[] pathParts = path.split("/"); List<String> parts = new ArrayList<>(pathParts.length); String pathSoFar = ""; for (String pathPart : pathParts) { if (!pathPart.equals("")) { pathSoFar += "/" + pathPart; parts.add(pathSoFar); } } return parts; }
ZooKeeperHelper { static List<String> pathParts(String path) { String[] pathParts = path.split("/"); List<String> parts = new ArrayList<>(pathParts.length); String pathSoFar = ""; for (String pathPart : pathParts) { if (!pathPart.equals("")) { pathSoFar += "/" + pathPart; parts.add(pathSoFar); } } return parts; } }
ZooKeeperHelper { static List<String> pathParts(String path) { String[] pathParts = path.split("/"); List<String> parts = new ArrayList<>(pathParts.length); String pathSoFar = ""; for (String pathPart : pathParts) { if (!pathPart.equals("")) { pathSoFar += "/" + pathPart; parts.add(pathSoFar); } } return parts; }  }
ZooKeeperHelper { static List<String> pathParts(String path) { String[] pathParts = path.split("/"); List<String> parts = new ArrayList<>(pathParts.length); String pathSoFar = ""; for (String pathPart : pathParts) { if (!pathPart.equals("")) { pathSoFar += "/" + pathPart; parts.add(pathSoFar); } } return parts; }   }
ZooKeeperHelper { static List<String> pathParts(String path) { String[] pathParts = path.split("/"); List<String> parts = new ArrayList<>(pathParts.length); String pathSoFar = ""; for (String pathPart : pathParts) { if (!pathPart.equals("")) { pathSoFar += "/" + pathPart; parts.add(pathSoFar); } } return parts; }    }