Beispiel #1
0
  private TreeNode<String> createTreeFromPaths(List<Path> paths) {
    TreeNode<String> result = new TreeNode<>("");

    // add all paths to the tree
    for (Path p : paths) {
      TreeNode<String> current = result;

      for (String e : p) {
        TreeNode<String> n = current.getChild(e);
        if (n == null) {
          n = new TreeNode<>(e);
          current.addChildren(n);
        }
        current = n;
      }
    }

    return result;
  }