Interface NodeVisitor<R>

Type Parameters:
R - The return type of the visitor.
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface NodeVisitor<R>
A visitor for visiting nodes in a Tree.
See Also:
  • Method Details

    • visit

      R visit(UUID nodeId, Optional<Class<? extends Node>> nodeType, Optional<String> displayName, Supplier<Node> node, Stream<Supplier<R>> nextVisitings) throws NodeProcessException
      The visit method for the visitor. This method will be called for the node that the visiting is starting from (depending on which of the AuthTree#visitNodes methods was called). The nextVisitings suppliers can then be invoked in order to carry on down the tree to the next nodes reachable from this one.

      Nodes will not be visited more than once - if a tree loops back to an earlier node, the node will not be visited again, and the nextVisitings will not include the outcomes that lead to the earlier node.

      Parameters:
      nodeId - The id of the node being visited.
      nodeType - An optional of the type of the node being visited, or empty if it's the success or failure node.
      displayName - An optional of the name of the node being visited, or empty if it's the success or failure node.
      node - A supplier that can be called to obtain the node instance, which will be null if it's the success or failure node.
      nextVisitings - A stream of suppliers that are called to invoke the visitor on the next nodes in the tree that are reachable from the current node. This will be empty if it's the success or failure node, or if all outcomes lead to an already visited node.
      Returns:
      The return value of the visitor.
      Throws:
      NodeProcessException - If there was an error processing the nodes.