Interface ExpressionChildrenMatcher

  • All Known Implementing Classes:
    AllChildrenMatcher, AnyChildMatcher, AnyChildrenMatcher, AnyChildWithRestMatcher, ListChildrenMatcher

    @API(EXPERIMENTAL)
    public interface ExpressionChildrenMatcher
    An ExpressionChildrenMatcher describes how to match the children of a RelationalExpression (i.e., the references returned by the RelationalExpression.getQuantifiers() 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 RelationalExpression.getQuantifiers() For example, an AndComponent can have an arbitrary number of other QueryComponents 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.

    • Method Detail

      • matches

        @Nonnull
        Stream<PlannerBindings> matches​(@Nonnull
                                        List<? extends Bindable> children)
        Apply this matcher to the children provided by the given iterator and produce a stream of possible bindings. If the match is not successful, produce an empty stream. Note that this method should not generally match to the children themselves; instead, it should delegate that work to one or more inner ExpressionMatchers.
        Parameters:
        children - a list of references to the children of a planner expression
        Returns:
        a stream of the possible bindings from applying this match to the children in the given iterator