Class Clauses


  • @API(status=EXPERIMENTAL,
         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 of the fluent API.
    Since:
    2021.3.0
    Author:
    Michael J. Simons
    • Method Detail

      • match

        @NotNull
        public static @NotNull Clause match​(boolean optional,
                                            List<PatternElement> patternElements,
                                            @Nullable
                                            @Nullable Expression optionalWhere,
                                            @Nullable
                                            @Nullable List<Hint> optionalHints)
        Builds a MATCH clause.
        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
      • delete

        @NotNull
        public static @NotNull 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

        @NotNull
        public static @NotNull Return returning​(boolean distinct,
                                                List<Expression> expressions,
                                                @Nullable
                                                @Nullable List<SortItem> optionalSortItems,
                                                @Nullable
                                                @Nullable Expression optionalSkip,
                                                @Nullable
                                                @Nullable 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

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

        @NotNull
        public static @NotNull Clause merge​(List<PatternElement> patternElements,
                                            @Nullable
                                            @Nullable 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,
                                  @Nullable
                                  @Nullable Expression 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 expression to define a where clause.
        Returns:
        an immutable with clause
      • 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,
                                     @Nullable
                                     @Nullable 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,
                                        @Nullable
                                        @Nullable List<Expression> arguments,
                                        @Nullable
                                        @Nullable List<Expression> resultItems,
                                        @Nullable
                                        @Nullable Expression 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
      • 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 subquery.
        Returns:
        An immutable subquery 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