Package org.terracotta.context.query
Class QueryBuilder
- java.lang.Object
-
- org.terracotta.context.query.QueryBuilder
-
public class QueryBuilder extends java.lang.ObjectAQueryBuilderallows 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.
-
-
Constructor Summary
Constructors Modifier Constructor Description privateQueryBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Querybuild()Returns a query that represents the currently assembled transformation.QueryBuilderchain(Query query)Applies the given query on the currently selected node set.QueryBuilderchildren()Selects the union of the current node sets child nodes.QueryBuilderdescendants()Selects the merged descendant set of the current node set.QueryBuilderempty()Selects an empty node set.QueryBuilderensureUnique()Asserts that the current node set is a singleton.QueryBuilderfilter(Matcher<? super TreeNode> filter)Filters the current node set using the suppliedMatcher.QueryBuilderparent()Selects the parent of the current node.static QueryBuilderqueryBuilder()Creates a new query builder instance.
-
-
-
Field Detail
-
current
private Query current
-
-
Method Detail
-
queryBuilder
public static QueryBuilder 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
public QueryBuilder filter(Matcher<? super TreeNode> 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
public QueryBuilder children()
Selects the union of the current node sets child nodes.- Returns:
- this query builder
-
parent
public QueryBuilder parent()
Selects the parent of the current node.- Returns:
- this query builder
-
descendants
public QueryBuilder 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
public QueryBuilder chain(Query query)
Applies the given query on the currently selected node set.- Parameters:
query- query to apply- Returns:
- this query builder
-
ensureUnique
public QueryBuilder 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
public QueryBuilder empty()
Selects an empty node set.- Returns:
- this query builder
-
build
public Query build()
Returns a query that represents the currently assembled transformation.- Returns:
- a newly constructed query
-
-