Interface QueryExpression<T extends DataObject>
- Type Parameters:
T
- Result object type
- All Superinterfaces:
Immutable
- All Known Implementing Classes:
DefaultQuery
An opaque query expression. A query execution results in a
QueryResult
, which is composed of zero or more
objects of the same type. Implementations of this interface are expected to be effectively-immutable and therefore
thread-safe and reusable.
While this interface does not expose any useful methods, it represents a well-defined concept, which is composed of three distinct parts:
- root path, which defines the subtree on which the expression is executed
- select path, which is a strict subset of the root path and defines which objects should be selected
- a set of predicates, which are to be evaluated on selected objects
For the purposes of illustration of how these three parts work together, let's imagine the following simple model:
module foo { list foo { key name; leaf name { type string; } leaf alias { type string; } container bar { list baz { key id; leaf id { type uint64; } leaf value { type string; } } } } }
We have two nested lists, each having two leaves -- one addressable as a key, one a plain property. There is a number of different queries we could perform on such a model:
- select all
baz
es which havevalue="foo"
- select all
baz
es underfoo[name="xyzzy"]
, which havevalue="foo"
- select all
foo
s which havealias="xyzzy"
- select all
foo
s which havealias="xyzzy"
and contain abaz[value="foo"]
Note how the first and second options differ in what is being searched:
- search for all
baz
entries needs to traverse allfoo
entries - search for all
baz
entries forfoo[name="xyzzy"]
needs to traverse only a single directly-addressable entry.
foo
list,
while the second will select a specific foo
entry.