Interface Evaluator<V,R>

Type Parameters:
V - the node type
R - the result type
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 Evaluator<V,R>
Extracts an optional result from a node as it is visited.

This is the Java-facing form of Visitor's Evaluable[V, R] type class: it is the "what do we want to know about this node" concern. Returning Optional.empty() records the visit but contributes nothing to TraversalResult.results(), so an evaluator doubles as a filter over the visited nodes.

An evaluator sees the node alone. It is not told which edge the node was reached by; if your decision depends on that, the traversal result's TraversalResult.cameFrom() map carries the predecessor after the fact.

  • Method Summary

    Modifier and Type
    Method
    Description
    evaluate(V node)
    Evaluates node.
  • Method Details

    • evaluate

      Optional<R> evaluate(V node)
      Evaluates node.
      Parameters:
      node - the node being visited
      Returns:
      the result for this node, or Optional.empty() to contribute none