@API(value=EXPERIMENTAL) public class PlannerBindings extends Object
Bindable
s, such as
PlannerExpression
s and ExpressionRef
s. A binding's key is a pointer to the ExpressionMatcher
that created the binding, eliminating the need for a unique string or symbol identifier. A PlannerBindings
is immutable but has a PlannerBindings.Builder
that can be used to build up a set of bindings incrementally. Additionally,
bindings can be combined using mergedWith(PlannerBindings)
.Modifier and Type | Class and Description |
---|---|
static class |
PlannerBindings.Builder
A mutable builder for a set of
PlannerBindings which can be used to incrementally build up a set of
bindings without repeatedly calling mergedWith(PlannerBindings) , which is less efficient. |
Modifier and Type | Method and Description |
---|---|
boolean |
containsKey(ExpressionMatcher<? extends Bindable> key)
Checks whether there is a bindable bound to
key . |
static PlannerBindings |
empty()
Return an empty set of bindings.
|
static PlannerBindings |
from(ExpressionMatcher<? extends Bindable> key,
Bindable bindable)
Build a new set of bindings containing a single binding from the given key to the given bindable.
|
<T extends Bindable> |
get(ExpressionMatcher<T> key)
Retrieve the single bindable bound to
key . |
<T extends Bindable> |
getAll(ExpressionMatcher<T> key)
Retrieve all bindables bound to
key if there is at least one such bindable. |
PlannerBindings |
mergedWith(PlannerBindings other)
Combine this set of bindings with the given set of bindings.
|
static PlannerBindings.Builder |
newBuilder()
Return a new builder.
|
public boolean containsKey(@Nonnull ExpressionMatcher<? extends Bindable> key)
key
.key
- a matcherkey
@Nonnull public <T extends Bindable> T get(@Nonnull ExpressionMatcher<T> key)
key
. This method is meant to be a convenient shortcut for the case
where the developer is certain that precisely one bindable could be bound to this key. If no bindable is bound to
this key, or if there are multiple Bindable
s bound to this key, this throws a NoSuchElementException
.T
- the type of Bindable
that was bound to key
key
- a matcherNoSuchElementException
- if the number of bindables bound to this key is not exactly one@Nonnull public <T extends Bindable> List<T> getAll(@Nonnull ExpressionMatcher<T> key)
key
if there is at least one such bindable. The bindables in the returned
list appear in same order as they appear in the list of children of the PlannerExpression
that produced
this set of bindings. If no bindable is bound to this key, throw a NoSuchElementException
.T
- the type of Bindable
that was bound to key
key
- a matcherNoSuchElementException
- if no bindable objects are bound to the given key@Nonnull public PlannerBindings mergedWith(@Nonnull PlannerBindings other)
other
- a set of bindings, which may share keys with this set of bindings@Nonnull public static PlannerBindings from(@Nonnull ExpressionMatcher<? extends Bindable> key, @Nonnull Bindable bindable)
key
- an expression matcherbindable
- a bindable objectkey
to bindable
@Nonnull public static PlannerBindings empty()
public static PlannerBindings.Builder newBuilder()