/** * Create an empty path in a tree * * @param path */ public void addPath(String... path) { if(path.length < 1) { logger.error("Path is empty"); } else _addGraphByPath(new LinkedList<String>(Arrays.asList(path)), null); }
/** * Add a graph node provided it's full path, the last element will be the * graph node name * * @param path * @param nodesGraph */ public void addGraphByPath(List<String> path, GraphNode nodesGraph) { if(path.size() < 1) { logger.error("Path is empty : " + path + " for graph " + nodesGraph.getGraphTitle()); } else _addGraphByPath(new LinkedList<String>(path), nodesGraph); }
private void _addGraphByPath(LinkedList<String> path, GraphNode nodesGraph) { if(path.size() == 1 && nodesGraph != null) { graphsSet.put(path.getLast(), nodesGraph); } else if(!path.isEmpty()) { String pathElem = path.removeFirst(); addChild(pathElem); getChildbyName(pathElem)._addGraphByPath(path, nodesGraph); } }