@API(value=EXPERIMENTAL) public interface ExpressionChildrenMatcher
ExpressionChildrenMatcher
describes how to match the children of a PlannerExpression
(i.e., the
references returned by the PlannerExpression.getPlannerExpressionChildren()
method). Bindings can be
retrieved from the rule call using the ExpressionChildMatcher
that produced them.
In most cases, the most natural way to bind to the children of a planner expression is by defining a matcher for each
child. This behavior is implemented in the ListChildrenMatcher
and exposed by the
TypeMatcher.of(Class, ExpressionMatcher[])
helper method. However, this does not work when there is no
a priori bound on the number of children returned by PlannerExpression.getPlannerExpressionChildren()
.
For example, an AndComponent
can have an arbitrary number of
other QueryComponent
s as children.
Note that an ExpressionChildrenMatcher
should generally only define how to distribute children to one or more
child matchers, and that these child matchers should generally match to the children themselves. For example, see
the implementation of ListChildrenMatcher
. Extreme care should be taken when implementing an
ExpressionChildrenMatcher
. In particular, expression matchers may (or may not) be reused between successive
rule calls and should be stateless. Additionally, implementors of ExpressionMatcher
must use the
(default) reference equals()
method.
Modifier and Type | Method and Description |
---|---|
Stream<PlannerBindings> |
matches(Iterator<? extends ExpressionRef<? extends PlannerExpression>> childIterator)
Apply this matcher to the children provided by the given iterator and produce a stream of possible bindings.
|
@Nonnull Stream<PlannerBindings> matches(@Nonnull Iterator<? extends ExpressionRef<? extends PlannerExpression>> childIterator)
ExpressionMatcher
s.childIterator
- an iterator of references to the children of a planner expression