Interface StatementCatalog


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
  • Method Details

    • label

      static StatementCatalog.Token label(String label)
      Convenience method to create node label tokens.
      Parameters:
      label - The label to be used
      Returns:
      A new label token
    • type

      static StatementCatalog.Token type(String type)
      Convenience method to create relationship type tokens.
      Parameters:
      type - The type to be used
      Returns:
      A new relationship type token
    • property

      static StatementCatalog.Property property(String name)
      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 owner
      name - The name of the property
      Returns:
      A new property
    • getAllTokens

      Returns a collection of all tokens used in the analyzed statement.
      Returns:
      A collection of all tokens used
    • getNodeLabels

      default Collection<StatementCatalog.Token> getNodeLabels()
      Returns a collection of all node labels used in the analyzed statement.
      Returns:
      A collection of all labels used
    • getRelationshipTypes

      default Collection<StatementCatalog.Token> 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 from getNodeLabels() to retrieve relationships that have a node with the given token as start node. Alternative, use label(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 from getRelationshipTypes() to retrieve target nodes of that relationship. Alternative, use type(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 from getNodeLabels() to retrieve relationships that have a node with the given token as end node. Alternative, use label(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 from getRelationshipTypes() to retrieve source nodes of that relationship. Alternative, use type(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 from getNodeLabels() to retrieve relationships that are connected to nodes with the given token. Alternative, use label(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

      Returns a collection of all properties resolved in the analyzed statement.
      Returns:
      A collection of all properties resolved
    • getAllFilters

      default Collection<StatementCatalog.Filter> getAllFilters()
      Returns a collection all filters resolved in the analyzed statement.
      Returns:
      A map of all filters.
    • getAllLabelFilters

      Returns a collection of all filters that checked for the existence of labels.
      Returns:
      A collection of all label filters
    • 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

      Map<String,Object> 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, use getParameterNames().

      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

      Map<String,String> getRenamedParameters()
      A statement can be configured to use generated names (see Configuration.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