Package com.phasmidsoftware.visitor.java
Interface Evaluator<V,R>
- Type Parameters:
V- the node typeR- 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.
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
-
Method Details
-
evaluate
Evaluatesnode.- Parameters:
node- the node being visited- Returns:
- the result for this node, or
Optional.empty()to contribute none
-