/** * Finds the node for the given path, and returns it or null if node was found.<p> * * @param path the path * @return the node for the path */ public CmsPathTree<P, V> findNode(List<P> path) { List<P> pathToConsume = Lists.newLinkedList(path); CmsPathTree<P, V> descendant = findNodeInternal(pathToConsume); if (!pathToConsume.isEmpty()) { return null; } else { return descendant; } }
/** * Returns the node for the given path, creating all nodes on the way if they don't already exist.<p> * * @param path the path for which to make sure a node exists * * @return the node for the path */ private CmsPathTree<P, V> ensureNode(List<P> path) { List<P> pathToConsume = Lists.newLinkedList(path); CmsPathTree<P, V> lastExistingNode = findNodeInternal(pathToConsume); CmsPathTree<P, V> currentNode = lastExistingNode; for (P pathPart : pathToConsume) { CmsPathTree<P, V> child = new CmsPathTree<P, V>(); currentNode.m_children.put(pathPart, child); currentNode = child; } return currentNode; }