@Test void nonEmptyPointersMustHaveLeadingSlash() { assertThrows(InvalidArgumentException.class, () -> PathTree.parseJsonPointer("foo")); }
static List<String> parseJsonPointer(String jsonPointer) { if (!jsonPointer.startsWith("/") && !jsonPointer.isEmpty()) { throw InvalidArgumentException.fromMessage("JSON pointer must be empty or start with forward slash (/) but got \"" + jsonPointer + "\""); } final int HONOR_ALL_DELIMITERS = -1; return Arrays.stream(jsonPointer.split("/", HONOR_ALL_DELIMITERS)) .map(s -> s.replace("~1", "/").replace("~0", "~")) .collect(toList()); }
PathTree { static List<String> parseJsonPointer(String jsonPointer) { if (!jsonPointer.startsWith("/") && !jsonPointer.isEmpty()) { throw InvalidArgumentException.fromMessage("JSON pointer must be empty or start with forward slash (/) but got \"" + jsonPointer + "\""); } final int HONOR_ALL_DELIMITERS = -1; return Arrays.stream(jsonPointer.split("/", HONOR_ALL_DELIMITERS)) .map(s -> s.replace("~1", "/").replace("~0", "~")) .collect(toList()); } }
PathTree { static List<String> parseJsonPointer(String jsonPointer) { if (!jsonPointer.startsWith("/") && !jsonPointer.isEmpty()) { throw InvalidArgumentException.fromMessage("JSON pointer must be empty or start with forward slash (/) but got \"" + jsonPointer + "\""); } final int HONOR_ALL_DELIMITERS = -1; return Arrays.stream(jsonPointer.split("/", HONOR_ALL_DELIMITERS)) .map(s -> s.replace("~1", "/").replace("~0", "~")) .collect(toList()); } private  PathTree(PathTree parent, String name); }
PathTree { static List<String> parseJsonPointer(String jsonPointer) { if (!jsonPointer.startsWith("/") && !jsonPointer.isEmpty()) { throw InvalidArgumentException.fromMessage("JSON pointer must be empty or start with forward slash (/) but got \"" + jsonPointer + "\""); } final int HONOR_ALL_DELIMITERS = -1; return Arrays.stream(jsonPointer.split("/", HONOR_ALL_DELIMITERS)) .map(s -> s.replace("~1", "/").replace("~0", "~")) .collect(toList()); } private  PathTree(PathTree parent, String name); @Override String toString(); }
PathTree { static List<String> parseJsonPointer(String jsonPointer) { if (!jsonPointer.startsWith("/") && !jsonPointer.isEmpty()) { throw InvalidArgumentException.fromMessage("JSON pointer must be empty or start with forward slash (/) but got \"" + jsonPointer + "\""); } final int HONOR_ALL_DELIMITERS = -1; return Arrays.stream(jsonPointer.split("/", HONOR_ALL_DELIMITERS)) .map(s -> s.replace("~1", "/").replace("~0", "~")) .collect(toList()); } private  PathTree(PathTree parent, String name); @Override String toString();  }