public sealed interface StatementCatalog
The statement catalog gives an overview about relevant items in a statement. These items include tokens (labels and
relationship types), the resolved properties for given sets of these tokens (those sets reassembling concrete
entities, think Nodes with one or more labels or relationships with a concrete type) as well as conditions in which
the properties have been used. This structural analysis can be used to predict how graph elements are accessed, or
they can be used to make sure certain conditions are contained within a statement.
Finally, the list of identifiable elements at the end of a statement (aka after a RETURN clause) is contained
in the catalog.
In addition, this interface provides the namespace for all elements that are represented as non-AST elements as part
of a catalog, such as the properties and property conditions.
Any instance of a catalog and its contents can be safely assumed to be immutable.
- Since:
- 2023.1.0
- Author:
- Michael J. Simons
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumEnum for the clause in which a comparison was made.static interfaceThis interface represents all kinds of filters in a query such as filters on labels and filters on properties.static final recordThis type represents a filter on nodes requiring one or more labels.static final recordA property that has been resolved.static final recordThis type encapsulates a comparison in which a property of a node or relationship was used.static final recordA token can either describe a node label or a relationship type. -
Method Summary
Modifier and TypeMethodDescriptiondefault Collection<StatementCatalog.Filter>Returns a collection all filters resolved in the analyzed statement.Returns a collection of all filters that checked for the existence of labels.Returns a map that contains all properties that have been used in a comparing condition as keys and a set of all comparisons they appeared in.Returns a collection of all tokens used in the analyzed statement.getFilters(StatementCatalog.Property property) Returns a collection of all property based filters in the statement involving the resolved properties.Returns a collection of all expressions that are identifiable expression in a non-void (or non-unit) Cypher statement.default Collection<StatementCatalog.Token>Returns a collection of all node labels used in the analyzed statement.After the statement has been build, this method returns a list of all parameter names used, regardless whether a value was bound to the parameter o not.After a statement has been build, all parameters that have been added to the statement can be retrieved through this method.Returns a collection of all properties resolved in the analyzed statement.default Collection<StatementCatalog.Token>Returns a collection of all relationship types used in the analyzed statement.A statement can be configured to use generated names (seeConfiguration.isUseGeneratedNames()).static StatementCatalog.TokenConvenience method to create node label tokens.static StatementCatalog.PropertyConvenience method to create a new property without a specific owner.static StatementCatalog.Propertyproperty(Set<StatementCatalog.Token> owner, String name) Convenience method to create a new property with a defined owner.static StatementCatalog.TokenConvenience method to create relationship type tokens.
-
Method Details
-
label
Convenience method to create node label tokens.- Parameters:
label- The label to be used- Returns:
- A new label token
-
type
Convenience method to create relationship type tokens.- Parameters:
type- The type to be used- Returns:
- A new relationship type token
-
property
Convenience method to create a new property without a specific owner.- Parameters:
name- The name of the property- Returns:
- A new property
-
property
Convenience method to create a new property with a defined owner.- Parameters:
owner- The set of tokens defining the ownername- The name of the property- Returns:
- A new property
-
getAllTokens
Collection<StatementCatalog.Token> getAllTokens()Returns a collection of all tokens used in the analyzed statement.- Returns:
- A collection of all tokens used
-
getNodeLabels
Returns a collection of all node labels used in the analyzed statement.- Returns:
- A collection of all labels used
-
getRelationshipTypes
Returns a collection of all relationship types used in the analyzed statement.- Returns:
- A collection of all types used
-
getProperties
Collection<StatementCatalog.Property> getProperties()Returns a collection of all properties resolved in the analyzed statement.- Returns:
- A collection of all properties resolved
-
getAllFilters
Returns a collection all filters resolved in the analyzed statement.- Returns:
- A map of all filters.
-
getAllLabelFilters
Collection<StatementCatalog.LabelFilter> getAllLabelFilters()Returns a collection of all filters that checked for the existence of labels.- Returns:
- A collection of all label filters
-
getAllPropertyFilters
Map<StatementCatalog.Property,Collection<StatementCatalog.PropertyFilter>> getAllPropertyFilters()Returns a map that contains all properties that have been used in a comparing condition as keys and a set of all comparisons they appeared in.- Returns:
- A map of all properties used in comparisons
-
getFilters
Returns a collection of all property based filters in the statement involving the resolved properties.- Returns:
- A collection of all conditions involving properties resolved in the statement
-
getIdentifiableExpressions
Collection<Expression> getIdentifiableExpressions()Returns a collection of all expressions that are identifiable expression in a non-void (or non-unit) Cypher statement. These expressions might refer to properties, but can be of course function calls, existential sub-queries and the like.- Returns:
- A collection of identifiable expressions.
-
getParameters
After a statement has been build, all parameters that have been added to the statement can be retrieved through this method. The result will only contain parameters with a defined value. If you are interested in all parameter names, usegetParameterNames().The map can be used for example as an argument with various methods on the Neo4j Java Driver that allow the execution of parameterized queries.
- Returns:
- A map of all parameters with a bound value.
- Since:
- 2023.2.0
-
getParameterNames
Collection<String> getParameterNames()After the statement has been build, this method returns a list of all parameter names used, regardless whether a value was bound to the parameter o not.- Returns:
- A set of parameter names being used.
- Since:
- 2023.2.0
-
getRenamedParameters
A statement can be configured to use generated names (seeConfiguration.isUseGeneratedNames()). This method returns the used remapping table.- Returns:
- A map of renamed parameters when
Configuration.isUseGeneratedNames()would be set to true
-