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
Modifier and TypeInterfaceDescriptionstatic enum
Enum for the clause in which a comparison was made.static interface
This interface represents all kinds of filters in a query such as filters on labels and filters on properties.static final record
This type represents a filter on nodes requiring one or more labels.static final record
A property that has been resolved.static final record
This type encapsulates a comparison in which a property of a node or relationship was used.static final record
A 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 filters applied on a specific property.Returns a collection of all expressions that are identifiable expression in a non-void (or non-unit) Cypher statement.This method can be used with any token returned fromgetNodeLabels()
to retrieve relationships that have a node with the given token as end node.Collection
<Literal<?>> default Collection
<StatementCatalog.Token> Returns a collection of all node labels used in the analyzed statement.This method can be used with any token returned fromgetNodeLabels()
to retrieve relationships that have a node with the given token as start node.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()
).This method can be used with any token returned fromgetRelationshipTypes()
to retrieve source nodes of that relationship.This method can be used with any token returned fromgetRelationshipTypes()
to retrieve target nodes of that relationship.This method can be used with any token returned fromgetNodeLabels()
to retrieve relationships that are connected to nodes with the given token.static StatementCatalog.Token
Convenience method to create node label tokens.static StatementCatalog.Property
Convenience method to create a new property without a specific owner.static StatementCatalog.Property
property
(Set<StatementCatalog.Token> owner, String name) Convenience method to create a new property with a defined owner.static StatementCatalog.Token
Convenience 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
-
getOutgoingRelations
This method can be used with any token returned fromgetNodeLabels()
to retrieve relationships that have a node with the given token as start node. Alternative, uselabel(String)
to build labels to query this method.- Parameters:
label
- The label to retrieve outgoing relations for- Returns:
- A set of tokens describing relations
- Since:
- 2023.3.0
-
getTargetNodes
This method can be used with any token returned fromgetRelationshipTypes()
to retrieve target nodes of that relationship. Alternative, usetype(String)
to build types to query this method.- Parameters:
type
- The type of relationship to retrieve target nodes- Returns:
- A set of tokens describing labels
- Since:
- 2023.3.0
-
getIncomingRelations
This method can be used with any token returned fromgetNodeLabels()
to retrieve relationships that have a node with the given token as end node. Alternative, uselabel(String)
to build labels to query this method.- Parameters:
label
- The label to retrieve incoming relations for- Returns:
- A set of tokens describing relations
- Since:
- 2023.3.0
-
getSourceNodes
This method can be used with any token returned fromgetRelationshipTypes()
to retrieve source nodes of that relationship. Alternative, usetype(String)
to build types to query this method.- Parameters:
type
- The type of relationship to retrieve source nodes- Returns:
- A set of tokens describing labels
- Since:
- 2023.3.0
-
getUndirectedRelations
This method can be used with any token returned fromgetNodeLabels()
to retrieve relationships that are connected to nodes with the given token. Alternative, uselabel(String)
to build labels to query this method.- Parameters:
label
- The label to retrieve relations for- Returns:
- A set of tokens describing relations
- Since:
- 2023.3.0
-
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 filters applied on a specific property.- Parameters:
property
- The property for which filter should be retrieved- 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
-
getLiterals
Collection<Literal<?>> getLiterals()- Returns:
- A collection of all literals used in a statement.
- Since:
- 2023.4.0
-