Package org.terracotta.context.query
Class QueryBuilder
java.lang.Object
org.terracotta.context.query.QueryBuilder
A
QueryBuilder allows for modular assembly of context graph queries.
Query assembly is performed by chaining a sequence of graph traversal and filtering operations together in order to select a particular set of the input node set's descendants.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Returns a query that represents the currently assembled transformation.Applies the given query on the currently selected node set.children()Selects the union of the current node sets child nodes.Selects the merged descendant set of the current node set.empty()Selects an empty node set.Asserts that the current node set is a singleton.Filters the current node set using the suppliedMatcher.parent()Selects the parent of the current node.static QueryBuilderCreates a new query builder instance.
-
Field Details
-
current
-
-
Constructor Details
-
QueryBuilder
private QueryBuilder()
-
-
Method Details
-
queryBuilder
Creates a new query builder instance.A newly constructed query builder represents the identity query. It simply returns the input node set as the output node set.
- Returns:
- a new query builder
-
filter
Filters the current node set using the suppliedMatcher.Nodes in the current node set that are not selected by the supplied matcher are removed.
- Parameters:
filter- matcher to apply- Returns:
- this query builder
-
children
Selects the union of the current node sets child nodes.- Returns:
- this query builder
-
parent
Selects the parent of the current node.- Returns:
- this query builder
-
descendants
Selects the merged descendant set of the current node set.More precisely this recursively merges the children of each member of the node-set in to the output node set until the set ceases to grow.
- Returns:
- this query builder
-
chain
Applies the given query on the currently selected node set.- Parameters:
query- query to apply- Returns:
- this query builder
-
ensureUnique
Asserts that the current node set is a singleton.If the current node set is not of size 1 then the query will terminate with an
IllegalStateException.- Returns:
- this query builder
-
empty
Selects an empty node set.- Returns:
- this query builder
-
build
Returns a query that represents the currently assembled transformation.- Returns:
- a newly constructed query
-