Class TypeMatcher<T extends Bindable>
- java.lang.Object
-
- com.apple.foundationdb.record.query.plan.temp.matchers.TypeMatcher<T>
-
- Type Parameters:
T
- the planner expression type that this matcher binds to
- All Implemented Interfaces:
ExpressionMatcher<T>
- Direct Known Subclasses:
QuantifierMatcher
,TypeWithPredicateMatcher
@API(EXPERIMENTAL) public class TypeMatcher<T extends Bindable> extends Object implements ExpressionMatcher<T>
A matcher that is specified by the class of its expression: to match any of several types of expressions, they must all implement a common interface (which itself extendsPlannerExpression
). The bindings produced by this matcher provide access to a single expression only, and allow it to be accessed by the rule.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
TypeMatcher(Class<? extends T> expressionClass, ExpressionChildrenMatcher childrenMatcher)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ExpressionChildrenMatcher
getChildrenMatcher()
Return the child matchers of this matcher as a list.Class<? extends Bindable>
getRootClass()
Get a class or interface extendingRelationalExpression
that is a super class of every planner expression that this matcher can match.Stream<PlannerBindings>
matchWith(ExpressionRef<? extends RelationalExpression> ref)
Attempt to match this matcher against the given expression reference.Stream<PlannerBindings>
matchWith(Quantifier quantifier)
Attempt to match this matcher against the givenQuantifier
.Stream<PlannerBindings>
matchWith(RelationalExpression expression)
Attempt to match this matcher against the givenExpressionMatcher
.Stream<PlannerBindings>
matchWith(QueryPredicate predicate)
Attempt to match this matcher against the givenQueryPredicate
.static <U extends Bindable>
TypeMatcher<U>of(Class<? extends U> expressionClass)
static <U extends Bindable>
TypeMatcher<U>of(Class<? extends U> expressionClass, ExpressionChildrenMatcher childrenMatcher)
static <U extends Bindable>
TypeMatcher<U>of(Class<? extends U> expressionClass, ExpressionMatcher<? extends Bindable>... children)
-
-
-
Constructor Detail
-
TypeMatcher
protected TypeMatcher(@Nonnull Class<? extends T> expressionClass, @Nonnull ExpressionChildrenMatcher childrenMatcher)
-
-
Method Detail
-
getRootClass
@Nonnull public Class<? extends Bindable> getRootClass()
Description copied from interface:ExpressionMatcher
Get a class or interface extendingRelationalExpression
that is a super class of every planner expression that this matcher can match. Ideally, it should be the lowest such class but it may not be. A planner will generally use this method to quickly determine a set of rules that could match an expression, without considering each rule and trying to apply it. A good implementation of this method helps the planner match rules efficiently.- Specified by:
getRootClass
in interfaceExpressionMatcher<T extends Bindable>
- Returns:
- a class object for a class that is a super class of every planner expression this matcher can match
-
getChildrenMatcher
@Nonnull public ExpressionChildrenMatcher getChildrenMatcher()
Description copied from interface:ExpressionMatcher
Return the child matchers of this matcher as a list.- Specified by:
getChildrenMatcher
in interfaceExpressionMatcher<T extends Bindable>
- Returns:
- a list of the child matchers of this matcher
-
of
public static <U extends Bindable> TypeMatcher<U> of(@Nonnull Class<? extends U> expressionClass)
-
of
@SafeVarargs public static <U extends Bindable> TypeMatcher<U> of(@Nonnull Class<? extends U> expressionClass, @Nonnull ExpressionMatcher<? extends Bindable>... children)
-
of
public static <U extends Bindable> TypeMatcher<U> of(@Nonnull Class<? extends U> expressionClass, @Nonnull ExpressionChildrenMatcher childrenMatcher)
-
matchWith
@Nonnull public Stream<PlannerBindings> matchWith(@Nonnull ExpressionRef<? extends RelationalExpression> ref)
Description copied from interface:ExpressionMatcher
Attempt to match this matcher against the given expression reference. Note that implementations ofmatchWith()
should only attempt to match the given root with this planner expression and should not call into theExpressionChildrenMatcher
returned byExpressionMatcher.getChildrenMatcher()
or attempt to access the members of the given reference.- Specified by:
matchWith
in interfaceExpressionMatcher<T extends Bindable>
- Parameters:
ref
- a reference to match with- Returns:
- a stream of
PlannerBindings
containing the matched bindings, or an empty stream is no match was found
-
matchWith
@Nonnull public Stream<PlannerBindings> matchWith(@Nonnull RelationalExpression expression)
Description copied from interface:ExpressionMatcher
Attempt to match this matcher against the givenExpressionMatcher
. Note that implementations ofmatchWith()
should only attempt to match the given root with this planner expression and should not call into theExpressionChildrenMatcher
returned byExpressionMatcher.getChildrenMatcher()
or attempt to access children of the given expression.- Specified by:
matchWith
in interfaceExpressionMatcher<T extends Bindable>
- Parameters:
expression
- a planner expression to match with- Returns:
- a stream of
PlannerBindings
containing the matched bindings, or an empty stream is no match was found
-
matchWith
@Nonnull public Stream<PlannerBindings> matchWith(@Nonnull QueryPredicate predicate)
Description copied from interface:ExpressionMatcher
Attempt to match this matcher against the givenQueryPredicate
. Note that implementations ofmatchWith()
should only attempt to match the given root with this planner expression and should not call into theExpressionChildrenMatcher
returned byExpressionMatcher.getChildrenMatcher()
or attempt to access children of the given expression.- Specified by:
matchWith
in interfaceExpressionMatcher<T extends Bindable>
- Parameters:
predicate
- a predicate to match with- Returns:
- a stream of
PlannerBindings
containing the matched bindings, or an empty stream is no match was found
-
matchWith
@Nonnull public Stream<PlannerBindings> matchWith(@Nonnull Quantifier quantifier)
Description copied from interface:ExpressionMatcher
Attempt to match this matcher against the givenQuantifier
. Note that implementations ofmatchWith()
should only attempt to match the given root with this planner expression and should not call into theExpressionChildrenMatcher
returned byExpressionMatcher.getChildrenMatcher()
or attempt to access children of the given expression.- Specified by:
matchWith
in interfaceExpressionMatcher<T extends Bindable>
- Parameters:
quantifier
- a quantifier to match with- Returns:
- a stream of
PlannerBindings
containing the matched bindings, or an empty stream is no match was found
-
-