Class Clauses

java.lang.Object
org.neo4j.cypherdsl.core.Clauses

@API(status=STABLE, since="2021.3.0") public final class Clauses extends Object
Builder / factory for various clauses. It's mostly useful for building a Cypher-DSL AST outside the fluent API.
Since:
2021.3.0
Author:
Michael J. Simons
  • Method Details

    • match

      public static Clause match(boolean optional, List<PatternElement> patternElements, Where optionalWhere, List<Hint> optionalHints)
      Builds a MATCH clause. The result can be safely cast to a Match if needed.
      Parameters:
      optional - should this be an optional match?
      patternElements - the pattern elements to match
      optionalWhere - an optional where sub-clause
      optionalHints - optional hints to be used
      Returns:
      an immutable match clause
      Since:
      2022.0.0
    • delete

      public static Clause delete(boolean detach, List<Expression> expressions)
      Builds a DELETE clause.
      Parameters:
      detach - should this be an detach delete?
      expressions - the expressions pointing to the things to be deleted
      Returns:
      an immutable delete clause
    • returning

      public static Return returning(boolean distinct, List<Expression> expressions, List<SortItem> optionalSortItems, Expression optionalSkip, Expression optionalLimit)
      Builds a RETURN clause.
      Parameters:
      distinct - should this be a distinct return
      expressions - the expressions to be returned
      optionalSortItems - an optional list of sort items
      optionalSkip - an optional NumberLiteral of how many items to skip
      optionalLimit - an optional NumberLiteral of how many items to be returned
      Returns:
      an immutable return clause
    • create

      public static Clause create(List<PatternElement> patternElements)
      Builds a CREATE clause.
      Parameters:
      patternElements - the pattern elements to create
      Returns:
      an immutable create clause
    • merge

      public static Clause merge(List<PatternElement> patternElements, List<MergeAction> mergeActions)
      Builds a MERGE clause.
      Parameters:
      patternElements - the pattern elements to merge
      mergeActions - an optional list of merge actions
      Returns:
      an immutable merge clause
    • with

      public static Clause with(Return returnClause, Where optionalWhere)
      Retrofits an existing return clause into an equivalent with clause, optionally adding a where.
      Parameters:
      returnClause - the return clause that defines the fields, order and limit of what the with clause should return
      optionalWhere - an optional WHERE expression to define a where clause.
      Returns:
      an immutable with clause
      Since:
      2022.0.0
    • remove

      public static Clause remove(List<Expression> expressions)
      Creates a remove clause, removing labels or properties.
      Parameters:
      expressions - expressions pointing to a list of properties or labels that shall be removed
      Returns:
      an immutable remove clause
    • set

      public static Clause set(List<Expression> expressions)
      Creates a remove clause, setting labels or properties.
      Parameters:
      expressions - expressions pointing to a list of properties or labels that shall be set
      Returns:
      an immutable set clause
    • unwind

      public static Clause unwind(Expression expression, SymbolicName name)
      Creates an unwind clause.
      Parameters:
      expression - the expression to unwind
      name - the name on which to unwind
      Returns:
      an immutable unwind clause
    • loadCSV

      public static Clause loadCSV(boolean withHeaders, StringLiteral uri, SymbolicName alias, String fieldTerminator)
      Creates an LOAD CSV clause.
      Parameters:
      withHeaders - set to true to render the WITH HEADERS options
      uri - the source to load from
      alias - the alias for the lines
      fieldTerminator - the field terminator
      Returns:
      an immutable clause
    • callClause

      public static Clause callClause(List<String> namespace, String name, List<Expression> arguments, List<Expression> resultItems, Where optionalWhere)
      Creates a CALL clause.
      Parameters:
      namespace - an optional namespace, maybe empty
      name - the name of the stored procedure to call
      arguments - the arguments, maybe null or empty
      resultItems - the result items, maybe null or empty
      optionalWhere - an optional where
      Returns:
      an immutable clause
      Since:
      2022.0.0
    • callClause

      public static Clause callClause(Statement statement)
      Creates a CALL {} sub-query clause. No checking is done whether the statement passed in returns anything meaningful so that the resulting clause will be runnable or not.
      Parameters:
      statement - a statement to be used inside the sub-query.
      Returns:
      an immutable sub-query clause.
    • forEach

      public static Clause forEach(SymbolicName v, Expression list, List<Clause> updatingClauses)
      Creates a literal for each clause.
      Parameters:
      v - the name of the variable that should be available in the list of updating clauses
      list - the list on which to iterate
      updatingClauses - the updating clauses
      Returns:
      an immutable foreach clause
    • orderBy

      public static Clause orderBy(List<SortItem> sortItems, Expression skip, Expression limit)
      Creates a standalone ORDER BY clause.
      Parameters:
      sortItems - the items to sort by
      skip - a literal number item specifying the skipped items, may be null
      limit - a literal number item specifying the total limit of items, may be null
      Returns:
      an immutable order by clause
      Since:
      2024.7.4