Class ListChildrenMatcher

  • All Implemented Interfaces:
    ExpressionChildrenMatcher

    public class ListChildrenMatcher
    extends Object
    implements ExpressionChildrenMatcher
    A matcher for a children that tries to match each child to a specified matcher. It implements the "default" matching for children, as exposed by the TypeMatcher.of(Class, ExpressionMatcher[]) helper method.

    If every child matches the specified matcher and if every matcher matches a child, the ListChildrenMatcher returns a stream of bindings that includes the Cartesian product of the stream of bindings from each child. Note that this matcher can only match a fixed number of children. Currently, matching is not especially efficient: the cross product is computed by collecting each child stream into a list.

    • Method Detail

      • matches

        @Nonnull
        public Stream<PlannerBindings> matches​(@Nonnull
                                               PlannerBindings outerBindings,
                                               @Nonnull
                                               List<? extends Bindable> children)
        Description copied from interface: ExpressionChildrenMatcher
        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.
        Specified by:
        matches in interface ExpressionChildrenMatcher
        Parameters:
        outerBindings - preexisting bindings supplied by the caller
        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
      • empty

        @Nonnull
        public static ListChildrenMatcher empty()
        Get a matcher with no child matchers which matches an empty collection of children. The returned matcher may be a static instance and may not be distinct across different calls. Unlike an ExpressionMatcher, an ExpressionChildrenMatcher is not used for creating bindings and so need not be a distinct object.
        Returns:
        a matcher that matches an empty collection of children
      • of

        @Nonnull
        public static ListChildrenMatcher of​(List<ExpressionMatcher<? extends Bindable>> childMatchers)
        Get a matcher that tries to match the planner expression children, in order, to the given list of ExpressionMatchers.
        Parameters:
        childMatchers - a list of matcher for the children, in order
        Returns:
        a matcher that attempts to match the children, in order, to the given list of matchers