Package org.neo4j.cypherdsl.core
Class Cypher
- java.lang.Object
-
- org.neo4j.cypherdsl.core.Cypher
-
@API(status=EXPERIMENTAL, since="1.0") public final class Cypher extends java.lang.ObjectThe main entry point into the Cypher DSL. The Cypher Builder API is intended for framework usage to produce Cypher statements required for database operations.- Since:
- 1.0
- Author:
- Michael J. Simons, Gerrit Meier
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static NodeanyNode()static NodeanyNode(java.lang.String symbolicName)static NodeanyNode(SymbolicName symbolicName)static Asteriskasterisk()static org.neo4j.cypherdsl.core.ProcedureCall.OngoingStandaloneCallWithoutArgumentscall(java.lang.String procedureName)Starts defining a procedure call of the procedure with the given procedureName.static org.neo4j.cypherdsl.core.ProcedureCall.OngoingStandaloneCallWithoutArgumentscall(java.lang.String... namespaceAndProcedure)Starts defining a procedure call of the procedure with the given qualified name.static CasecaseExpression()static CasecaseExpression(Expression expression)static <T extends StatementBuilder.OngoingUpdate & StatementBuilder.ExposesSet>
Tcreate(PatternElement... pattern)Starts building a statement based on aCREATEclause.static PatternComprehension.OngoingDefinitionWithPatternlistBasedOn(Relationship pattern)static PatternComprehension.OngoingDefinitionWithPatternlistBasedOn(RelationshipChain pattern)static ListExpressionlistOf(Expression... expressions)Creates alist-expressionfrom several expressions.static ListComprehension.OngoingDefinitionWithVariablelistWith(SymbolicName variable)Starts defining alist comprehension.static LiteralliteralFalse()static Literal<?>literalOf(java.lang.Object object)Creates a newNullLiteralfrom the givenobject.static LiteralliteralTrue()static MapExpressionmapOf(java.lang.Object... keysAndValues)Creates a map of expression from a list of key/value pairs.static StatementBuilder.OngoingReadingWithoutWherematch(PatternElement... pattern)Starts building a statement based on a match clause.static <T extends StatementBuilder.OngoingUpdate & StatementBuilder.ExposesSet>
Tmerge(PatternElement... pattern)Starts building a statement based on aMERGEclause.static SymbolicNamename(java.lang.String value)Creates a new symbolic name.static Nodenode(java.lang.String primaryLabel, java.lang.String... additionalLabels)Create a new Node representation with at least one label, the "primary" label.static Nodenode(java.lang.String primaryLabel, java.util.List<java.lang.String> additionalLabels)static Nodenode(java.lang.String primaryLabel, MapExpression properties, java.lang.String... additionalLabels)static StatementBuilder.OngoingReadingWithoutWhereoptionalMatch(PatternElement... pattern)Prepares an optional match statement.static Parameterparameter(java.lang.String name)Creates a new parameter placeholder.static NamedPath.OngoingDefinitionWithNamepath(java.lang.String name)Starts defining a named path by indicating a name.static NamedPath.OngoingDefinitionWithNamepath(SymbolicName name)Starts defining a named path by indicating a name.static Propertyproperty(java.lang.String containerName, java.lang.String name)Dereferences a property for a symbolic name, most likely pointing to a property container like a node or a relationship.static Propertyproperty(Expression expression, java.lang.String name)Dereferences a property on a arbitrary expression.static java.lang.Stringquote(java.lang.String unquotedString)Escapes and quotes theunquotedStringfor safe usage in Neo4j-Browser and Shell.static StatementBuilder.OngoingReadingAndReturnreturning(Expression... expressions)A RETURN statement without a previous match.static NamedPath.OngoingShortestPathDefinitionWithNameshortestPath(java.lang.String name)Starts defining a named path defined by theshortestPathbetween a relationship by indicating a name.static NamedPath.OngoingShortestPathDefinitionWithNameshortestPath(SymbolicName name)Starts defining a named path defined by theshortestPathbetween a relationship by indicating a name.static SortItemsort(Expression expression)static Statementunion(Statement... statement)static StatementunionAll(Statement... statement)static StatementBuilder.OngoingUnwindunwind(Expression expression)Starts building a statement starting with anUNWINDclause.static StatementBuilder.OngoingUnwindunwind(Expression... expressions)Starts building a statement starting with anUNWINDclause.static StatementBuilder.OrderableOngoingReadingAndWithwith(AliasedExpression... expressions)Starts a statement with a leadingWITH.
-
-
-
Method Detail
-
node
public static Node node(java.lang.String primaryLabel, java.lang.String... additionalLabels)
Create a new Node representation with at least one label, the "primary" label. This is required. All other labels are optional.- Parameters:
primaryLabel- The primary label this node is identified by.additionalLabels- Additional labels- Returns:
- A new node representation
-
node
public static Node node(java.lang.String primaryLabel, java.util.List<java.lang.String> additionalLabels)
-
node
public static Node node(java.lang.String primaryLabel, MapExpression properties, java.lang.String... additionalLabels)
-
anyNode
public static Node anyNode()
- Returns:
- A node matching any node.
-
asterisk
public static Asterisk asterisk()
- Returns:
- The
*wildcard literal.
-
anyNode
public static Node anyNode(java.lang.String symbolicName)
- Parameters:
symbolicName- The new symbolic name- Returns:
- A node matching any node with the symbolic the given
symbolicName.
-
anyNode
public static Node anyNode(SymbolicName symbolicName)
- Parameters:
symbolicName- The new symbolic name- Returns:
- A node matching any node with the symbolic the given
symbolicName.
-
property
public static Property property(java.lang.String containerName, java.lang.String name)
Dereferences a property for a symbolic name, most likely pointing to a property container like a node or a relationship.- Parameters:
containerName- The symbolic name of a property containername- The name of the property to dereference- Returns:
- A new property
-
property
public static Property property(Expression expression, java.lang.String name)
Dereferences a property on a arbitrary expression.- Parameters:
expression- The expression that describes some sort of accessible mapname- The name of the property to dereference- Returns:
- A new property.
-
path
public static NamedPath.OngoingDefinitionWithName path(java.lang.String name)
Starts defining a named path by indicating a name.- Parameters:
name- The name of the new path- Returns:
- An ongoing definition of a named path
- Since:
- 1.1
-
path
public static NamedPath.OngoingDefinitionWithName path(SymbolicName name)
Starts defining a named path by indicating a name.- Parameters:
name- The name of the new path- Returns:
- An ongoing definition of a named path
- Since:
- 1.1
-
shortestPath
public static NamedPath.OngoingShortestPathDefinitionWithName shortestPath(java.lang.String name)
Starts defining a named path defined by theshortestPathbetween a relationship by indicating a name.- Parameters:
name- The name of the new shortestPath path- Returns:
- An ongoing definition of a named path
- Since:
- 1.1.1
-
shortestPath
public static NamedPath.OngoingShortestPathDefinitionWithName shortestPath(SymbolicName name)
Starts defining a named path defined by theshortestPathbetween a relationship by indicating a name.- Parameters:
name- The name of the new shortestPath path- Returns:
- An ongoing definition of a named path
- Since:
- 1.1.1
-
name
public static SymbolicName name(java.lang.String value)
Creates a new symbolic name.- Parameters:
value- The value of the symbolic name- Returns:
- A new symbolic name
-
parameter
public static Parameter parameter(java.lang.String name)
Creates a new parameter placeholder. Existing $-signs will be removed.- Parameters:
name- The name of the parameter, must not be null- Returns:
- The new parameter
-
optionalMatch
public static StatementBuilder.OngoingReadingWithoutWhere optionalMatch(PatternElement... pattern)
Prepares an optional match statement.- Parameters:
pattern- The patterns to match- Returns:
- An ongoing match that is used to specify an optional where and a required return clause
-
match
public static StatementBuilder.OngoingReadingWithoutWhere match(PatternElement... pattern)
Starts building a statement based on a match clause. Usenode(String, String...)and related to retrieve a node or a relationship, which both are pattern elements.- Parameters:
pattern- The patterns to match- Returns:
- An ongoing match that is used to specify an optional where and a required return clause
-
create
public static <T extends StatementBuilder.OngoingUpdate & StatementBuilder.ExposesSet> T create(PatternElement... pattern)
Starts building a statement based on aCREATEclause.- Type Parameters:
T- The type of the next step- Parameters:
pattern- The patterns to create- Returns:
- An ongoing
CREATEthat can be used to specifyWITHandRETURNINGetc.
-
with
public static StatementBuilder.OrderableOngoingReadingAndWith with(AliasedExpression... expressions)
Starts a statement with a leadingWITH. Those are useful for passing on lists of various type that can be unwound later on etc. A leadingWITHcannot be used with patterns obviously and needs its arguments to have an alias.- Parameters:
expressions- One ore more aliased expressions.- Returns:
- An ongoing with clause.
-
merge
public static <T extends StatementBuilder.OngoingUpdate & StatementBuilder.ExposesSet> T merge(PatternElement... pattern)
Starts building a statement based on aMERGEclause.- Type Parameters:
T- The type of the next step- Parameters:
pattern- The patterns to merge- Returns:
- An ongoing
MERGEthat can be used to specifyWITHandRETURNINGetc.
-
unwind
public static StatementBuilder.OngoingUnwind unwind(Expression expression)
Starts building a statement starting with anUNWINDclause. The expression needs to be an expression evaluating to a list, otherwise the query will fail.- Parameters:
expression- The expression to unwind- Returns:
- An ongoing
UNWIND.
-
unwind
public static StatementBuilder.OngoingUnwind unwind(Expression... expressions)
Starts building a statement starting with anUNWINDclause. The expressions passed will be turned into a list expression- Parameters:
expressions- expressions to unwind- Returns:
- a new instance of
StatementBuilder.OngoingUnwind
-
sort
public static SortItem sort(Expression expression)
- Parameters:
expression- The expression by which things should be sorted- Returns:
- A sort item, providing means to specify ascending or descending order
-
mapOf
public static MapExpression mapOf(java.lang.Object... keysAndValues)
Creates a map of expression from a list of key/value pairs.- Parameters:
keysAndValues- A list of key and values. Must be an even number, with alternatingStringandExpression- Returns:
- A new map expression.
-
listOf
public static ListExpression listOf(Expression... expressions)
Creates alist-expressionfrom several expressions.- Parameters:
expressions- expressions to get combined into a list- Returns:
- a new instance of
ListExpression
-
literalOf
public static Literal<?> literalOf(java.lang.Object object)
Creates a newNullLiteralfrom the givenobject.- Parameters:
object- the object to represent.- Returns:
- a new
NullLiteral. - Throws:
java.lang.IllegalArgumentException- when the object cannot be represented as a literal
-
literalTrue
public static Literal literalTrue()
- Returns:
- The true literal.
-
literalFalse
public static Literal literalFalse()
- Returns:
- The false literal.
-
returning
public static StatementBuilder.OngoingReadingAndReturn returning(Expression... expressions)
A RETURN statement without a previous match.- Parameters:
expressions- The expressions to return- Returns:
- A buildable statement
- Since:
- 1.0.1
-
listBasedOn
public static PatternComprehension.OngoingDefinitionWithPattern listBasedOn(Relationship pattern)
-
listBasedOn
public static PatternComprehension.OngoingDefinitionWithPattern listBasedOn(RelationshipChain pattern)
-
listWith
public static ListComprehension.OngoingDefinitionWithVariable listWith(SymbolicName variable)
Starts defining alist comprehension.- Parameters:
variable- The variable to which each element of the list is assigned.- Returns:
- An ongoing definition of a list comprehension
- Since:
- 1.0.1
-
quote
public static java.lang.String quote(java.lang.String unquotedString)
Escapes and quotes theunquotedStringfor safe usage in Neo4j-Browser and Shell.- Parameters:
unquotedString- An unquoted string- Returns:
- A quoted string with special chars escaped.
-
caseExpression
public static Case caseExpression()
- Returns:
- generic case expression start
-
caseExpression
public static Case caseExpression(Expression expression)
- Parameters:
expression- initial expression for the simple case statement- Returns:
- simple case expression start
-
call
public static org.neo4j.cypherdsl.core.ProcedureCall.OngoingStandaloneCallWithoutArguments call(java.lang.String procedureName)
Starts defining a procedure call of the procedure with the given procedureName. That procedure name might be fully qualified - that is, including a namespace - or just a simple name.- Parameters:
procedureName- The procedure name of the procedure to call. Might be fully qualified.- Returns:
- An ongoing definition of a call
-
call
public static org.neo4j.cypherdsl.core.ProcedureCall.OngoingStandaloneCallWithoutArguments call(java.lang.String... namespaceAndProcedure)
Starts defining a procedure call of the procedure with the given qualified name.- Parameters:
namespaceAndProcedure- The procedure name of the procedure to call.- Returns:
- An ongoing definition of a call
-
-