T
- the planner expression type that this matcher binds to@API(value=EXPERIMENTAL) public class TypeMatcher<T extends PlannerExpression> extends Object implements ExpressionMatcher<T>
PlannerExpression
). The bindings produced by this
matcher provide access to a single expression only, and allow it to be accessed by the rule.Modifier and Type | Method and Description |
---|---|
ExpressionChildrenMatcher |
getChildrenMatcher()
Return the child matchers of this matcher as a list.
|
Class<? extends T> |
getRootClass()
Get a class or interface extending
PlannerExpression that is a super class of every planner expression
that this matcher can match. |
Stream<PlannerBindings> |
matchWith(ExpressionRef<? extends PlannerExpression> ref)
Attempt to match this matcher against the given expression reference.
|
Stream<PlannerBindings> |
matchWith(PlannerExpression expression)
Attempt to match this matcher against the given expression reference.
|
static <U extends PlannerExpression> |
of(Class<? extends U> expressionClass) |
static <U extends PlannerExpression> |
of(Class<? extends U> expressionClass,
ExpressionChildrenMatcher childrenMatcher) |
static <U extends PlannerExpression> |
of(Class<? extends U> expressionClass,
ExpressionMatcher<? extends Bindable>... children) |
@Nonnull public Class<? extends T> getRootClass()
ExpressionMatcher
PlannerExpression
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.getRootClass
in interface ExpressionMatcher<T extends PlannerExpression>
@Nonnull public ExpressionChildrenMatcher getChildrenMatcher()
ExpressionMatcher
getChildrenMatcher
in interface ExpressionMatcher<T extends PlannerExpression>
public static <U extends PlannerExpression> TypeMatcher<U> of(@Nonnull Class<? extends U> expressionClass)
@SafeVarargs public static <U extends PlannerExpression> TypeMatcher<U> of(@Nonnull Class<? extends U> expressionClass, @Nonnull ExpressionMatcher<? extends Bindable>... children)
public static <U extends PlannerExpression> TypeMatcher<U> of(@Nonnull Class<? extends U> expressionClass, @Nonnull ExpressionChildrenMatcher childrenMatcher)
@Nonnull public Stream<PlannerBindings> matchWith(@Nonnull ExpressionRef<? extends PlannerExpression> ref)
ExpressionMatcher
matchWith()
should only attempt to match the given root with this planner
expression and should not call into the ExpressionChildrenMatcher
returned by ExpressionMatcher.getChildrenMatcher()
or attempt to access the members of the given reference.matchWith
in interface ExpressionMatcher<T extends PlannerExpression>
ref
- a reference to match withPlannerBindings
containing the matched bindings, or an empty stream is no match was found@Nonnull public Stream<PlannerBindings> matchWith(@Nonnull PlannerExpression expression)
ExpressionMatcher
matchWith()
should only attempt to match the given root with this planner
expression and should not call into the ExpressionChildrenMatcher
returned by ExpressionMatcher.getChildrenMatcher()
or attempt to access children of the given expression.matchWith
in interface ExpressionMatcher<T extends PlannerExpression>
expression
- a planner expression to match withPlannerBindings
containing the matched bindings, or an empty stream is no match was found