IdentifierManager { @Nullable public Tree getTree(String identifier) { if (identifier.startsWith("/")) { return root.getTree(identifier); } else { int k = identifier.indexOf('/'); String uuid = k == -1 ? identifier : identifier.substring(0, k); checkArgument(UUIDUtils.isValidUUID(uuid), "Not a valid identifier '" + identifier + '\''); String basePath = resolveUUID(uuid); if (basePath == null) { return null; } else if (k == -1) { return root.getTree(basePath); } else { return root.getTree(PathUtils.concat(basePath, identifier.substring(k + 1))); } } } IdentifierManager(Root root); @NotNull static String generateUUID(); @NotNull static String generateUUID(String hint); static boolean isValidUUID(String uuid); @NotNull static String getIdentifier(Tree tree); @Nullable Tree getTree(String identifier); @Nullable String getPath(String identifier); @Nullable String getPath(PropertyState referenceValue); @Nullable String getPath(PropertyValue referenceValue); @NotNull Iterable<String> getReferences(boolean weak, @NotNull Tree tree, @Nullable final String propertyName); @NotNull Iterable<String> getReferences(@NotNull Tree tree, @NotNull final String propertyName,
                                          @NotNull String ntName, boolean weak); @Nullable String resolveUUID(String uuid);  }
@Test public void getTreeTest() { assertEquals("/", identifierManager.getTree(ID_ROOT).getPath()); assertEquals(PATH_X1, identifierManager.getTree(ID_X1).getPath()); assertEquals(PATH_Y1, identifierManager.getTree(ID_Y1).getPath()); assertEquals(PATH_Z1, identifierManager.getTree(ID_Z1).getPath()); assertNull(identifierManager.getTree(ID_NON_EXISTING)); try { identifierManager.getTree(ID_INVALID); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }