Permalink
Browse files

Optimized imports and fixed layouting according to Neo4j standards

  • Loading branch information...
1 parent e0f3d0d commit 6ac8445ce129bde63ba49fab0870b8fc989d32e0 @rickardoberg rickardoberg committed Jun 29, 2012
Showing with 990 additions and 844 deletions.
  1. +1 −1 src/main/java/org/neo4j/cypherdsl/AsString.java
  2. +257 −206 src/main/java/org/neo4j/cypherdsl/CypherQuery.java
  3. +28 −23 src/main/java/org/neo4j/cypherdsl/Identifier.java
  4. +16 −8 src/main/java/org/neo4j/cypherdsl/Literal.java
  5. +2 −2 src/main/java/org/neo4j/cypherdsl/Order.java
  6. +4 −4 src/main/java/org/neo4j/cypherdsl/Parameter.java
  7. +39 −41 src/main/java/org/neo4j/cypherdsl/Path.java
  8. +31 −30 src/main/java/org/neo4j/cypherdsl/PathRelationship.java
  9. +9 −9 src/main/java/org/neo4j/cypherdsl/Property.java
  10. +1 −1 src/main/java/org/neo4j/cypherdsl/SetProperty.java
  11. +3 −3 src/main/java/org/neo4j/cypherdsl/expression/All.java
  12. +4 −3 src/main/java/org/neo4j/cypherdsl/expression/BooleanExpression.java
  13. +2 −2 src/main/java/org/neo4j/cypherdsl/expression/CollectionExpression.java
  14. +8 −5 src/main/java/org/neo4j/cypherdsl/expression/Expression.java
  15. +1 −1 src/main/java/org/neo4j/cypherdsl/expression/NodeExpression.java
  16. +28 −19 src/main/java/org/neo4j/cypherdsl/expression/NumericExpression.java
  17. +1 −1 src/main/java/org/neo4j/cypherdsl/expression/PathExpression.java
  18. +1 −1 src/main/java/org/neo4j/cypherdsl/expression/PropertyContainerExpression.java
  19. +1 −1 src/main/java/org/neo4j/cypherdsl/expression/ReferenceExpression.java
  20. +1 −1 src/main/java/org/neo4j/cypherdsl/expression/RelationshipExpression.java
  21. +2 −2 src/main/java/org/neo4j/cypherdsl/expression/ScalarExpression.java
  22. +25 −25 src/main/java/org/neo4j/cypherdsl/expression/StartExpression.java
  23. +18 −11 src/main/java/org/neo4j/cypherdsl/expression/StringExpression.java
  24. +3 −2 src/main/java/org/neo4j/cypherdsl/grammar/Create.java
  25. +3 −2 src/main/java/org/neo4j/cypherdsl/grammar/Delete.java
  26. +5 −4 src/main/java/org/neo4j/cypherdsl/grammar/Execute.java
  27. +1 −1 src/main/java/org/neo4j/cypherdsl/grammar/ExecuteWithParameters.java
  28. +1 −1 src/main/java/org/neo4j/cypherdsl/grammar/ForEach.java
  29. +12 −11 src/main/java/org/neo4j/cypherdsl/grammar/ForEachStatement.java
  30. +10 −3 src/main/java/org/neo4j/cypherdsl/grammar/ForEachStatements.java
  31. +2 −2 src/main/java/org/neo4j/cypherdsl/grammar/Limit.java
  32. +4 −3 src/main/java/org/neo4j/cypherdsl/grammar/Match.java
  33. +4 −3 src/main/java/org/neo4j/cypherdsl/grammar/OrderBy.java
  34. +3 −2 src/main/java/org/neo4j/cypherdsl/grammar/Relate.java
  35. +2 −1 src/main/java/org/neo4j/cypherdsl/grammar/Return.java
  36. +1 −1 src/main/java/org/neo4j/cypherdsl/grammar/ReturnNext.java
  37. +3 −2 src/main/java/org/neo4j/cypherdsl/grammar/Set.java
  38. +2 −2 src/main/java/org/neo4j/cypherdsl/grammar/Skip.java
  39. +2 −1 src/main/java/org/neo4j/cypherdsl/grammar/Start.java
  40. +1 −1 src/main/java/org/neo4j/cypherdsl/grammar/StartNext.java
  41. +1 −1 src/main/java/org/neo4j/cypherdsl/grammar/Update.java
  42. +1 −1 src/main/java/org/neo4j/cypherdsl/grammar/UpdateNext.java
  43. +2 −2 src/main/java/org/neo4j/cypherdsl/grammar/Where.java
  44. +3 −2 src/main/java/org/neo4j/cypherdsl/grammar/With.java
  45. +1 −1 src/main/java/org/neo4j/cypherdsl/grammar/WithNext.java
  46. +12 −12 src/main/java/org/neo4j/cypherdsl/query/AbstractExpression.java
  47. +1 −1 src/main/java/org/neo4j/cypherdsl/query/ExpressionCollection.java
  48. +9 −7 src/main/java/org/neo4j/cypherdsl/query/Expressions.java
  49. +4 −5 src/main/java/org/neo4j/cypherdsl/query/Extract.java
  50. +4 −4 src/main/java/org/neo4j/cypherdsl/query/Filter.java
  51. +1 −6 src/main/java/org/neo4j/cypherdsl/query/FunctionExpression.java
  52. +4 −4 src/main/java/org/neo4j/cypherdsl/query/IterablePredicateExpression.java
  53. +2 −2 src/main/java/org/neo4j/cypherdsl/query/NamedPath.java
  54. +19 −19 src/main/java/org/neo4j/cypherdsl/query/NullHandling.java
  55. +6 −3 src/main/java/org/neo4j/cypherdsl/query/Operator.java
  56. +8 −6 src/main/java/org/neo4j/cypherdsl/query/OrderByExpression.java
  57. +2 −2 src/main/java/org/neo4j/cypherdsl/query/PropertyValue.java
  58. +2 −2 src/main/java/org/neo4j/cypherdsl/query/PropertyValues.java
  59. +40 −29 src/main/java/org/neo4j/cypherdsl/query/Query.java
  60. +6 −4 src/main/java/org/neo4j/cypherdsl/query/Regexp.java
  61. +1 −1 src/main/java/org/neo4j/cypherdsl/query/SuffixFunctionExpression.java
  62. +56 −53 src/main/java/org/neo4j/cypherdsl/query/Value.java
  63. +12 −6 src/main/java/org/neo4j/cypherdsl/query/clause/Clause.java
  64. +3 −2 src/main/java/org/neo4j/cypherdsl/query/clause/CreateClause.java
  65. +3 −3 src/main/java/org/neo4j/cypherdsl/query/clause/DeleteClause.java
  66. +22 −21 src/main/java/org/neo4j/cypherdsl/query/clause/ForEachClause.java
  67. +1 −1 src/main/java/org/neo4j/cypherdsl/query/clause/LimitClause.java
  68. +3 −2 src/main/java/org/neo4j/cypherdsl/query/clause/MatchClause.java
  69. +4 −3 src/main/java/org/neo4j/cypherdsl/query/clause/OrderByClause.java
  70. +3 −2 src/main/java/org/neo4j/cypherdsl/query/clause/RelateClause.java
  71. +3 −2 src/main/java/org/neo4j/cypherdsl/query/clause/ReturnClause.java
  72. +3 −2 src/main/java/org/neo4j/cypherdsl/query/clause/SetClause.java
  73. +1 −1 src/main/java/org/neo4j/cypherdsl/query/clause/SkipClause.java
  74. +3 −2 src/main/java/org/neo4j/cypherdsl/query/clause/StartClause.java
  75. +3 −2 src/main/java/org/neo4j/cypherdsl/query/clause/WhereClause.java
  76. +3 −2 src/main/java/org/neo4j/cypherdsl/query/clause/WithClause.java
  77. +6 −6 src/main/java/org/neo4j/cypherdsl/query/neo4j/StartExpressionNeo.java
  78. +148 −143 src/main/java/org/neo4j/cypherdsl/querydsl/CypherQueryDSL.java
  79. +14 −13 src/main/java/org/neo4j/cypherdsl/querydsl/Projection.java
  80. +28 −22 src/main/java/org/neo4j/cypherdsl/result/JSONSerializer.java
View
2 src/main/java/org/neo4j/cypherdsl/AsString.java
@@ -29,5 +29,5 @@
*
* @param builder
*/
- void asString(StringBuilder builder);
+ void asString( StringBuilder builder );
}
View
463 src/main/java/org/neo4j/cypherdsl/CypherQuery.java
@@ -19,9 +19,13 @@
*/
package org.neo4j.cypherdsl;
+import static org.neo4j.cypherdsl.query.Query.checkEmpty;
+import static org.neo4j.cypherdsl.query.Query.checkNull;
+
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
+
import org.neo4j.cypherdsl.expression.All;
import org.neo4j.cypherdsl.expression.BooleanExpression;
import org.neo4j.cypherdsl.expression.CollectionExpression;
@@ -80,12 +84,10 @@
import org.neo4j.cypherdsl.query.clause.WhereClause;
import org.neo4j.cypherdsl.query.clause.WithClause;
-import static org.neo4j.cypherdsl.query.Query.*;
-
/**
* DSL for creating Cypher queries. Once created you can serialize to a string,
* or retrieve the internal Query model for further processing.
- *
+ * <p/>
* It is possible to iteratively construct Cypher queries by calling toQuery()
* and then use the Query as continuation point. When a new CypherQuery is created
* by using the newQuery() method the Query is cloned, so that the original Query
@@ -114,10 +116,10 @@ public static StartNext start( StartExpression... startExpressions )
* @param paths
* @return
*/
- public static UpdateNext create(PathExpression... paths)
+ public static UpdateNext create( PathExpression... paths )
{
- CypherQuery query = new CypherQuery( );
- return query.creates(paths);
+ CypherQuery query = new CypherQuery();
+ return query.creates( paths );
}
/**
@@ -137,15 +139,14 @@ public static CypherQuery newQuery( Query query )
/**
* Use this constructor if you want to use the instantiation block style
* of using the DSL.
- *
+ * <p/>
* Example:
* <pre>
* new CypherQuery()
* {{
* starts(node("n",1)).returns(identifier("n"));
* }}.toString()
* </pre>
- *
*/
public CypherQuery()
{
@@ -158,7 +159,7 @@ private CypherQuery( Query query )
{
this.query = (Query) query.clone();
}
- catch( CloneNotSupportedException e )
+ catch ( CloneNotSupportedException e )
{
throw new IllegalStateException( "Query was not cloneable" );
}
@@ -167,17 +168,16 @@ private CypherQuery( Query query )
// Common -------------------------------------------------------
/**
- *
* Declare a Cypher query parameter.
* This will be replaced with {name}.
*
* @param name of the parameter
* @return Parameter instance
*/
- public static Parameter param(String name)
+ public static Parameter param( String name )
{
checkEmpty( name, "Name" );
- return new Parameter(name);
+ return new Parameter( name );
}
/**
@@ -189,7 +189,7 @@ public static Parameter param(String name)
public static StringExpression literal( String value )
{
checkNull( value, "Value" );
- return new Literal(value);
+ return new Literal( value );
}
/**
@@ -201,7 +201,7 @@ public static StringExpression literal( String value )
public static NumericExpression literal( Number value )
{
checkNull( value, "Value" );
- return new Literal(value);
+ return new Literal( value );
}
/**
@@ -212,12 +212,12 @@ public static NumericExpression literal( Number value )
*/
public static BooleanExpression literal( boolean value )
{
- return new Literal(value);
+ return new Literal( value );
}
/**
* Declare a literal value using an untyped object.
- *
+ * <p/>
* If a string is passed in, then output will
* be quoted appropriately.
*
@@ -227,13 +227,13 @@ public static BooleanExpression literal( boolean value )
public static ScalarExpression literal( Object value )
{
checkNull( value, "Value" );
- return new Literal(value);
+ return new Literal( value );
}
/**
* Declare an identifier. This is used to
* refer to names declared elsewhere in the query.
- *
+ * <p/>
* If you want to refer to properties, then create
* this first, and then call e.g. id.property("propname")
*
@@ -243,13 +243,13 @@ public static ScalarExpression literal( Object value )
public static Identifier identifier( String name )
{
checkEmpty( name, "Identifier" );
- return new Identifier(name);
+ return new Identifier( name );
}
/**
* Declare a collection of expressions. Values may be Expressions or literal values
* that are converted to Literal expressions by this method.
- *
+ * <p/>
* Corresponds to:
* <pre>
* [value1,value2,value3]
@@ -261,12 +261,12 @@ public static Identifier identifier( String name )
public static CollectionExpression collection( Object... values )
{
Expression[] expressions = new Expression[values.length];
- for( int i = 0; i < values.length; i++ )
+ for ( int i = 0; i < values.length; i++ )
{
- Object value = values[ i ];
+ Object value = values[i];
expressions[i] = value instanceof Expression ? (Expression) value : literal( value );
}
- return new Value(new ExpressionCollection(new Expressions( expressions )));
+ return new Value( new ExpressionCollection( new Expressions( expressions ) ) );
}
/**
@@ -278,9 +278,9 @@ public static CollectionExpression collection( Object... values )
public static Identifier[] identifiers( String... values )
{
Identifier[] identifiers = new Identifier[values.length];
- for( int i = 0; i < values.length; i++ )
+ for ( int i = 0; i < values.length; i++ )
{
- String value = values[ i ];
+ String value = values[i];
identifiers[i] = identifier( value );
}
return identifiers;
@@ -295,9 +295,9 @@ public static CollectionExpression collection( Object... values )
public static Parameter[] parameters( String... names )
{
Parameter[] parameters = new Parameter[names.length];
- for( int i = 0; i < names.length; i++ )
+ for ( int i = 0; i < names.length; i++ )
{
- String value = names[ i ];
+ String value = names[i];
parameters[i] = param( value );
}
return parameters;
@@ -313,9 +313,9 @@ public static CollectionExpression collection( Object... values )
public static NumericExpression[] literals( long... values )
{
NumericExpression[] literals = new NumericExpression[values.length];
- for( int i = 0; i < values.length; i++ )
+ for ( int i = 0; i < values.length; i++ )
{
- long value = values[ i ];
+ long value = values[i];
literals[i] = literal( value );
}
return literals;
@@ -329,9 +329,9 @@ public static CollectionExpression collection( Object... values )
* @param value
* @return
*/
- public static PropertyValue value(String id, Object value )
+ public static PropertyValue value( String id, Object value )
{
- return new PropertyValue( identifier( id), literal(value) );
+ return new PropertyValue( identifier( id ), literal( value ) );
}
/**
@@ -342,9 +342,9 @@ public static PropertyValue value(String id, Object value )
* @param value
* @return
*/
- public static PropertyValue value(String id, Expression value )
+ public static PropertyValue value( String id, Expression value )
{
- return new PropertyValue( identifier( id), value );
+ return new PropertyValue( identifier( id ), value );
}
/**
@@ -355,7 +355,7 @@ public static PropertyValue value(String id, Expression value )
* @param value
* @return
*/
- public static PropertyValue value(Identifier id, Expression value )
+ public static PropertyValue value( Identifier id, Expression value )
{
return new PropertyValue( id, value );
}
@@ -366,10 +366,10 @@ public static PropertyValue value(Identifier id, Expression value )
* @param expressions
* @return
*/
- public static BooleanExpression and(BooleanExpression... expressions)
+ public static BooleanExpression and( BooleanExpression... expressions )
{
Query.checkNull( expressions, "Expressions" );
- return new And(expressions);
+ return new And( expressions );
}
/**
@@ -378,15 +378,15 @@ public static BooleanExpression and(BooleanExpression... expressions)
* @param expressions
* @return
*/
- public static BooleanExpression or(BooleanExpression... expressions)
+ public static BooleanExpression or( BooleanExpression... expressions )
{
Query.checkNull( expressions, "Expressions" );
return new Or( expressions );
}
/**
* Invert the boolean value of a predicate.
- *
+ * <p/>
* Corresponds to:
* <pre>
* not(expression)
@@ -395,11 +395,11 @@ public static BooleanExpression or(BooleanExpression... expressions)
* @param expression
* @return
*/
- public static BooleanExpression not(BooleanExpression expression)
+ public static BooleanExpression not( BooleanExpression expression )
{
Query.checkNull( expression, "Expression" );
- return new Value( new FunctionExpression("not", expression));
+ return new Value( new FunctionExpression( "not", expression ) );
}
/**
@@ -411,9 +411,9 @@ public static BooleanExpression not(BooleanExpression expression)
* @param property
* @return
*/
- public static BooleanExpression has(Property property)
+ public static BooleanExpression has( Property property )
{
- return new Value(new FunctionExpression( "has", property ));
+ return new Value( new FunctionExpression( "has", property ) );
}
/**
@@ -425,9 +425,9 @@ public static BooleanExpression has(Property property)
* @param expression
* @return
*/
- public static BooleanExpression isNull(Expression expression)
+ public static BooleanExpression isNull( Expression expression )
{
- return new Value(new SuffixFunctionExpression( " is null", expression ));
+ return new Value( new SuffixFunctionExpression( " is null", expression ) );
}
/**
@@ -439,12 +439,13 @@ public static BooleanExpression isNull(Expression expression)
* @param expression
* @return
*/
- public static BooleanExpression isNotNull(Expression expression)
+ public static BooleanExpression isNotNull( Expression expression )
{
- return new Value(new SuffixFunctionExpression( " is not null", expression ));
+ return new Value( new SuffixFunctionExpression( " is not null", expression ) );
}
// Start --------------------------------------------------------
+
/**
* START clause. Use this with Java initialization block style.
*
@@ -453,7 +454,7 @@ public static BooleanExpression isNotNull(Expression expression)
*/
protected StartNext starts( StartExpression... startExpressions )
{
- query.add( new StartClause( Arrays.asList( startExpressions) ));
+ query.add( new StartClause( Arrays.asList( startExpressions ) ) );
return new Grammar();
}
@@ -466,7 +467,7 @@ protected StartNext starts( StartExpression... startExpressions )
*/
protected StartNext starts( Iterable<StartExpression> startExpressions )
{
- query.add( new StartClause( startExpressions ));
+ query.add( new StartClause( startExpressions ) );
return new Grammar();
}
@@ -477,7 +478,7 @@ protected StartNext starts( Iterable<StartExpression> startExpressions )
* @param paths
* @return
*/
- protected UpdateNext creates(PathExpression... paths)
+ protected UpdateNext creates( PathExpression... paths )
{
query.add( new CreateClause( Arrays.asList( paths ) ) );
@@ -513,9 +514,9 @@ protected UpdateNext creates(PathExpression... paths)
{
checkNull( name, "Name" );
- for( long i : id )
+ for ( long i : id )
{
- if( i < 0 )
+ if ( i < 0 )
{
throw new IllegalArgumentException( "Id may not be below zero" );
}
@@ -625,7 +626,8 @@ protected UpdateNext creates(PathExpression... paths)
* @param value
* @return
*/
- public static StartExpression.StartNodesLookup lookup( Identifier name, Identifier indexName, ReferenceExpression key, StringExpression value )
+ public static StartExpression.StartNodesLookup lookup( Identifier name, Identifier indexName,
+ ReferenceExpression key, StringExpression value )
{
checkEmpty( name, "Name" );
checkEmpty( indexName, "Index" );
@@ -707,9 +709,9 @@ protected UpdateNext creates(PathExpression... paths)
{
checkNull( name, "Name" );
- for( long i : id )
+ for ( long i : id )
{
- if( i < 0 )
+ if ( i < 0 )
{
throw new IllegalArgumentException( "Id may not be below zero" );
}
@@ -753,7 +755,8 @@ protected UpdateNext creates(PathExpression... paths)
checkNull( name, "Name" );
checkEmpty( parameter, "Parameter" );
- StartExpression.StartRelationshipsParameters startRelationships = new StartExpression.StartRelationshipsParameters();
+ StartExpression.StartRelationshipsParameters startRelationships = new StartExpression
+ .StartRelationshipsParameters();
startRelationships.name = name;
startRelationships.parameter = parameter;
return startRelationships;
@@ -771,7 +774,8 @@ protected UpdateNext creates(PathExpression... paths)
* @param value
* @return
*/
- public static StartExpression.StartRelationshipsIndex relationshipLookup( String name, String indexName, String key, String value )
+ public static StartExpression.StartRelationshipsIndex relationshipLookup( String name, String indexName,
+ String key, String value )
{
return relationshipLookup( identifier( name ), identifier( indexName ), identifier( key ), literal( value ) );
}
@@ -788,7 +792,8 @@ protected UpdateNext creates(PathExpression... paths)
* @param value
* @return
*/
- public static StartExpression.StartRelationshipsIndex relationshipLookup( Identifier name, Identifier indexName, Identifier key, StringExpression value )
+ public static StartExpression.StartRelationshipsIndex relationshipLookup( Identifier name, Identifier indexName,
+ Identifier key, StringExpression value )
{
checkNull( name, "Name" );
checkNull( indexName, "Index" );
@@ -807,7 +812,7 @@ protected UpdateNext creates(PathExpression... paths)
/**
* Start declaring a path for CREATE, RELATE, MATCH or WHERE clauses.
- *
+ * <p/>
* Corresponds to:
* <pre>
* ()
@@ -817,42 +822,44 @@ protected UpdateNext creates(PathExpression... paths)
*/
public static Path node()
{
- return new Path(null, null);
+ return new Path( null, null );
}
/**
* Start declaring a path for CREATE, RELATE, MATCH or WHERE clauses.
- *
+ * <p/>
* Corresponds to:
* <pre>
* (id)
* </pre>
+ *
* @param id
* @return
*/
- public static Path node(String id)
+ public static Path node( String id )
{
- return node( identifier( id ));
+ return node( identifier( id ) );
}
/**
* Start declaring a path for CREATE, RELATE, MATCH or WHERE clauses.
- *
+ * <p/>
* Corresponds to:
* <pre>
* (expression)
* </pre>
+ *
* @param expression
* @return
*/
- public static Path node(Expression expression)
+ public static Path node( Expression expression )
{
- return new Path(expression, null);
+ return new Path( expression, null );
}
/**
* Declare a named path for MATCH clauses
- *
+ * <p/>
* Corresponds to:
* <pre>
* name=path
@@ -861,14 +868,14 @@ public static Path node(Expression expression)
* @param name
* @return
*/
- public static PathExpression path(String name, PathExpression path)
+ public static PathExpression path( String name, PathExpression path )
{
- return path(identifier( name ), path);
+ return path( identifier( name ), path );
}
/**
* Declare a named path for MATCH clauses
- *
+ * <p/>
* Corresponds to:
* <pre>
* name=path
@@ -877,15 +884,15 @@ public static PathExpression path(String name, PathExpression path)
* @param name
* @return
*/
- public static PathExpression path(Identifier name, PathExpression path)
+ public static PathExpression path( Identifier name, PathExpression path )
{
checkNull( name, "Name" );
return new NamedPath( name, path );
}
/**
* Use this to declare a shortestPath.
- *
+ * <p/>
* Corresponds to:
* <pre>
* shortestPath(path)
@@ -897,12 +904,12 @@ public static PathExpression path(Identifier name, PathExpression path)
public static PathExpression shortestPath( PathExpression path )
{
Query.checkNull( path, "Path" );
- return new Value( new FunctionExpression("shortestPath", path));
+ return new Value( new FunctionExpression( "shortestPath", path ) );
}
/**
* Use this to declare a allShortestPaths
- *
+ * <p/>
* Corresponds to:
* <pre>
* allShortestPaths(path)
@@ -915,13 +922,14 @@ public static PathExpression allShortestPaths( PathExpression path )
{
Query.checkNull( path, "Path" );
- return new Value( new FunctionExpression("allShortestPaths", path));
+ return new Value( new FunctionExpression( "allShortestPaths", path ) );
}
// Return -------------------------------------------------------
+
/**
* Use this to rename identifiers for RETURN or WITH
- *
+ * <p/>
* Corresponds to:
* <pre>
* expression AS name
@@ -931,14 +939,14 @@ public static PathExpression allShortestPaths( PathExpression path )
* @param name
* @return
*/
- public static Expression as(Expression expression, String name)
+ public static Expression as( Expression expression, String name )
{
- return new Value(new Operator(expression, " AS "), identifier( name ));
+ return new Value( new Operator( expression, " AS " ), identifier( name ) );
}
/**
* Use this to rename identifiers for RETURN or WITH
- *
+ * <p/>
* Corresponds to:
* <pre>
* expression AS name
@@ -948,14 +956,14 @@ public static Expression as(Expression expression, String name)
* @param name
* @return
*/
- public static Expression as(Expression expression, Identifier name)
+ public static Expression as( Expression expression, Identifier name )
{
- return new Value(new Operator(expression, " AS "), name);
+ return new Value( new Operator( expression, " AS " ), name );
}
/**
* Use this to declare DISTINCT
- *
+ * <p/>
* Corresponds to:
* <pre>
* DISTINCT expression
@@ -964,9 +972,9 @@ public static Expression as(Expression expression, Identifier name)
* @param expression
* @return
*/
- public static Expression distinct(Expression expression)
+ public static Expression distinct( Expression expression )
{
- return new Value(new Operator("DISTINCT "), expression);
+ return new Value( new Operator( "DISTINCT " ), expression );
}
/**
@@ -976,26 +984,26 @@ public static Expression distinct(Expression expression)
*/
public static NumericExpression count()
{
- return new Value(new FunctionExpression("count", new AbstractExpression()
+ return new Value( new FunctionExpression( "count", new AbstractExpression()
{
@Override
public void asString( StringBuilder builder )
{
builder.append( '*' );
}
- }));
+ } ) );
}
/**
* Declare a count(expression) RETURN expression
*
* @return
*/
- public static NumericExpression count(Expression expression)
+ public static NumericExpression count( Expression expression )
{
checkNull( expression, "Expression" );
- return new Value(new FunctionExpression("count", expression));
+ return new Value( new FunctionExpression( "count", expression ) );
}
/**
@@ -1011,57 +1019,58 @@ public static All all()
*
* @return
*/
- public static NumericExpression sum(NumericExpression expression)
+ public static NumericExpression sum( NumericExpression expression )
{
checkNull( expression, "Expression" );
- return new Value( new FunctionExpression("sum", expression));
+ return new Value( new FunctionExpression( "sum", expression ) );
}
/**
* Declare a avg(expression) RETURN expression
*
* @return
*/
- public static NumericExpression avg(Expression expression)
+ public static NumericExpression avg( Expression expression )
{
checkNull( expression, "Expression" );
- return new Value( new FunctionExpression("avg", expression));
+ return new Value( new FunctionExpression( "avg", expression ) );
}
/**
* Declare a max(expression) RETURN expression
*
* @return
*/
- public static NumericExpression max(NumericExpression expression)
+ public static NumericExpression max( NumericExpression expression )
{
checkNull( expression, "Expression" );
- return new Value( new FunctionExpression("max", expression));
+ return new Value( new FunctionExpression( "max", expression ) );
}
/**
* Declare a min(expression) RETURN expression
*
* @return
*/
- public static NumericExpression min(NumericExpression expression)
+ public static NumericExpression min( NumericExpression expression )
{
checkNull( expression, "Expression" );
- return new Value( new FunctionExpression("min", expression));
+ return new Value( new FunctionExpression( "min", expression ) );
}
/**
* Declare a collect(expression) RETURN expression
*
* @return
*/
- public static CollectionExpression collect(ScalarExpression expression)
+ public static CollectionExpression collect( ScalarExpression expression )
{
checkNull( expression, "Expression" );
- return new Value(new FunctionExpression("collect", expression));
+ return new Value( new FunctionExpression( "collect", expression ) );
}
// Order by -----------------------------------------------------
+
/**
* Declare an ORDER clause expression. Typically used with identifier("n").property("property") as
* parameter.
@@ -1097,6 +1106,7 @@ public static OrderByExpression order( Expression expression, Order order )
}
// For each -----------------------------------------------------
+
/**
* Use this to create expressions for use with the FOR EACH clause. Use
* the fluent API of ForEachStatements to create the statements to be evaluated
@@ -1106,9 +1116,9 @@ public static OrderByExpression order( Expression expression, Order order )
* @param in
* @return
*/
- public static ForEachStatements in(String id, Expression in)
+ public static ForEachStatements in( String id, Expression in )
{
- return new ForEachClause( identifier(id), in );
+ return new ForEachClause( identifier( id ), in );
}
/**
@@ -1120,15 +1130,16 @@ public static ForEachStatements in(String id, Expression in)
* @param in
* @return
*/
- public static ForEachStatements in(Identifier id, Expression in)
+ public static ForEachStatements in( Identifier id, Expression in )
{
return new ForEachClause( id, in );
}
// Set ----------------------------------------------------------
+
/**
* Use this to set properties in the SET clause.
- *
+ * <p/>
* Corresponds to:
* <pre>
* property=value
@@ -1138,12 +1149,13 @@ public static ForEachStatements in(Identifier id, Expression in)
* @param value
* @return
*/
- public static SetProperty property(Property property, Expression value )
+ public static SetProperty property( Property property, Expression value )
{
return new SetProperty( property, value );
}
// Functions ----------------------------------------------------
+
/**
* Declare an ALL expression. Corresponds to:
* <pre>
@@ -1155,7 +1167,8 @@ public static SetProperty property(Property property, Expression value )
* @param predicateExpression
* @return
*/
- public static BooleanExpression all( String name, CollectionExpression iterable, BooleanExpression predicateExpression )
+ public static BooleanExpression all( String name, CollectionExpression iterable,
+ BooleanExpression predicateExpression )
{
return all( identifier( name ), iterable, predicateExpression );
}
@@ -1171,7 +1184,8 @@ public static BooleanExpression all( String name, CollectionExpression iterable,
* @param predicateExpression
* @return
*/
- public static BooleanExpression all( Identifier name, CollectionExpression iterable, BooleanExpression predicateExpression )
+ public static BooleanExpression all( Identifier name, CollectionExpression iterable,
+ BooleanExpression predicateExpression )
{
Query.checkNull( name, "Name" );
Query.checkNull( iterable, "Iterable" );
@@ -1182,7 +1196,7 @@ public static BooleanExpression all( Identifier name, CollectionExpression itera
expression.name = name;
expression.iterable = iterable;
expression.predicate = predicateExpression;
- return new Value( expression);
+ return new Value( expression );
}
/**
@@ -1196,7 +1210,8 @@ public static BooleanExpression all( Identifier name, CollectionExpression itera
* @param predicateExpression
* @return
*/
- public static BooleanExpression any( String name, CollectionExpression iterable, BooleanExpression predicateExpression )
+ public static BooleanExpression any( String name, CollectionExpression iterable,
+ BooleanExpression predicateExpression )
{
return any( identifier( name ), iterable, predicateExpression );
}
@@ -1212,7 +1227,8 @@ public static BooleanExpression any( String name, CollectionExpression iterable,
* @param predicateExpression
* @return
*/
- public static BooleanExpression any( Identifier name, CollectionExpression iterable, BooleanExpression predicateExpression )
+ public static BooleanExpression any( Identifier name, CollectionExpression iterable,
+ BooleanExpression predicateExpression )
{
Query.checkNull( name, "Name" );
Query.checkNull( iterable, "Iterable" );
@@ -1223,7 +1239,7 @@ public static BooleanExpression any( Identifier name, CollectionExpression itera
expression.name = name;
expression.iterable = iterable;
expression.predicate = predicateExpression;
- return new Value( expression);
+ return new Value( expression );
}
/**
@@ -1237,7 +1253,8 @@ public static BooleanExpression any( Identifier name, CollectionExpression itera
* @param predicateExpression
* @return
*/
- public static BooleanExpression none( String name, CollectionExpression iterable, BooleanExpression predicateExpression )
+ public static BooleanExpression none( String name, CollectionExpression iterable,
+ BooleanExpression predicateExpression )
{
return none( identifier( name ), iterable, predicateExpression );
}
@@ -1253,7 +1270,8 @@ public static BooleanExpression none( String name, CollectionExpression iterable
* @param predicateExpression
* @return
*/
- public static BooleanExpression none( Identifier name, CollectionExpression iterable, BooleanExpression predicateExpression )
+ public static BooleanExpression none( Identifier name, CollectionExpression iterable,
+ BooleanExpression predicateExpression )
{
Query.checkNull( name, "Name" );
Query.checkNull( iterable, "Iterable" );
@@ -1264,7 +1282,7 @@ public static BooleanExpression none( Identifier name, CollectionExpression iter
expression.name = name;
expression.iterable = iterable;
expression.predicate = predicateExpression;
- return new Value( expression);
+ return new Value( expression );
}
/**
@@ -1278,7 +1296,8 @@ public static BooleanExpression none( Identifier name, CollectionExpression iter
* @param predicateExpression
* @return
*/
- public static BooleanExpression single( String name, CollectionExpression iterable, BooleanExpression predicateExpression )
+ public static BooleanExpression single( String name, CollectionExpression iterable,
+ BooleanExpression predicateExpression )
{
return single( identifier( name ), iterable, predicateExpression );
}
@@ -1294,7 +1313,8 @@ public static BooleanExpression single( String name, CollectionExpression iterab
* @param predicateExpression
* @return
*/
- public static BooleanExpression single( Identifier name, CollectionExpression iterable, BooleanExpression predicateExpression )
+ public static BooleanExpression single( Identifier name, CollectionExpression iterable,
+ BooleanExpression predicateExpression )
{
Query.checkNull( name, "Name" );
Query.checkNull( iterable, "Iterable" );
@@ -1305,10 +1325,11 @@ public static BooleanExpression single( Identifier name, CollectionExpression it
expression.name = name;
expression.iterable = iterable;
expression.predicate = predicateExpression;
- return new Value( expression);
+ return new Value( expression );
}
// Scalar expressions
+
/**
* Declare a length expression. Corresponds to:
* <pre>
@@ -1318,10 +1339,10 @@ public static BooleanExpression single( Identifier name, CollectionExpression it
* @param expression
* @return
*/
- public static NumericExpression length(CollectionExpression expression)
+ public static NumericExpression length( CollectionExpression expression )
{
checkNull( expression, "Expression" );
- return new Value( new FunctionExpression("length", expression));
+ return new Value( new FunctionExpression( "length", expression ) );
}
/**
@@ -1333,10 +1354,10 @@ public static NumericExpression length(CollectionExpression expression)
* @param relationshipExpression
* @return
*/
- public static StringExpression type(RelationshipExpression relationshipExpression)
+ public static StringExpression type( RelationshipExpression relationshipExpression )
{
checkNull( relationshipExpression, "Expression" );
- return new Value(new FunctionExpression("type", relationshipExpression));
+ return new Value( new FunctionExpression( "type", relationshipExpression ) );
}
/**
@@ -1348,10 +1369,10 @@ public static StringExpression type(RelationshipExpression relationshipExpressio
* @param name
* @return
*/
- public static NumericExpression id(String name)
+ public static NumericExpression id( String name )
{
checkNull( name, "Name" );
- return new Value( new FunctionExpression("id", identifier( name )));
+ return new Value( new FunctionExpression( "id", identifier( name ) ) );
}
/**
@@ -1363,10 +1384,10 @@ public static NumericExpression id(String name)
* @param propertyContainerExpression
* @return
*/
- public static NumericExpression id(PropertyContainerExpression propertyContainerExpression)
+ public static NumericExpression id( PropertyContainerExpression propertyContainerExpression )
{
checkNull( propertyContainerExpression, "Expression" );
- return new Value( new FunctionExpression("id", propertyContainerExpression));
+ return new Value( new FunctionExpression( "id", propertyContainerExpression ) );
}
/**
@@ -1378,14 +1399,14 @@ public static NumericExpression id(PropertyContainerExpression propertyContainer
* @param expressions
* @return
*/
- public static Value coalesce(Expression... expressions)
+ public static Value coalesce( Expression... expressions )
{
- if( expressions.length < 1 )
+ if ( expressions.length < 1 )
{
throw new IllegalArgumentException( "At least one expression must be provided to coalesce function" );
}
- return new Value( new FunctionExpression("coalesce", new Expressions( expressions )));
+ return new Value( new FunctionExpression( "coalesce", new Expressions( expressions ) ) );
}
/**
@@ -1397,10 +1418,10 @@ public static Value coalesce(Expression... expressions)
* @param collectionExpression
* @return
*/
- public static Expression head(CollectionExpression collectionExpression)
+ public static Expression head( CollectionExpression collectionExpression )
{
checkNull( collectionExpression, "Expression" );
- return new Value( new FunctionExpression("head", collectionExpression));
+ return new Value( new FunctionExpression( "head", collectionExpression ) );
}
/**
@@ -1412,10 +1433,10 @@ public static Expression head(CollectionExpression collectionExpression)
* @param collectionExpression
* @return
*/
- public static Expression last(CollectionExpression collectionExpression)
+ public static Expression last( CollectionExpression collectionExpression )
{
checkNull( collectionExpression, "Expression" );
- return new Value( new FunctionExpression("last", collectionExpression));
+ return new Value( new FunctionExpression( "last", collectionExpression ) );
}
// Iterable expressions
@@ -1425,41 +1446,45 @@ public static Expression last(CollectionExpression collectionExpression)
* <pre>
* nodes(path)
* </pre>
+ *
* @param pathExpression
* @return
*/
- public static CollectionExpression nodes(PathExpression pathExpression)
+ public static CollectionExpression nodes( PathExpression pathExpression )
{
checkNull( pathExpression, "Expression" );
- return new Value( new FunctionExpression("nodes", pathExpression));
+ return new Value( new FunctionExpression( "nodes", pathExpression ) );
}
/**
* Declare a relationships expression. Corresponds to:
* <pre>
* relationships(path)
* </pre>
+ *
* @param pathExpression
* @return
*/
- public static CollectionExpression relationships(PathExpression pathExpression)
+ public static CollectionExpression relationships( PathExpression pathExpression )
{
checkNull( pathExpression, "Expression" );
- return new Value( new FunctionExpression("relationships", pathExpression));
+ return new Value( new FunctionExpression( "relationships", pathExpression ) );
}
/**
* Declare an extract expression. Corresponds to:
* <pre>
* extract(name IN iterable : expression)
* </pre>
+ *
* @param iterable
* @param expression
* @return
*/
- public static CollectionExpression extract( String name, CollectionExpression iterable, ScalarExpression expression )
+ public static CollectionExpression extract( String name, CollectionExpression iterable,
+ ScalarExpression expression )
{
return extract( identifier( name ), iterable, expression );
}
@@ -1469,11 +1494,13 @@ public static CollectionExpression extract( String name, CollectionExpression it
* <pre>
* extract(name IN iterable : expression)
* </pre>
+ *
* @param iterable
* @param expression
* @return
*/
- public static CollectionExpression extract( Identifier name, CollectionExpression iterable, ScalarExpression expression )
+ public static CollectionExpression extract( Identifier name, CollectionExpression iterable,
+ ScalarExpression expression )
{
Query.checkNull( name, "Name" );
Query.checkNull( iterable, "Iterable" );
@@ -1483,19 +1510,21 @@ public static CollectionExpression extract( Identifier name, CollectionExpressio
extract.name = name;
extract.iterable = iterable;
extract.expression = expression;
- return new Value( extract);
+ return new Value( extract );
}
/**
* Declare a filter expression. Corresponds to:
* <pre>
* filter(name IN iterable : predicate)
* </pre>
+ *
* @param iterable
* @param predicateExpression
* @return
*/
- public static CollectionExpression filter( String name, CollectionExpression iterable, BooleanExpression predicateExpression )
+ public static CollectionExpression filter( String name, CollectionExpression iterable,
+ BooleanExpression predicateExpression )
{
return filter( identifier( name ), iterable, predicateExpression );
}
@@ -1505,11 +1534,13 @@ public static CollectionExpression filter( String name, CollectionExpression ite
* <pre>
* filter(name IN iterable : predicate)
* </pre>
+ *
* @param iterable
* @param predicateExpression
* @return
*/
- public static CollectionExpression filter( Identifier name, CollectionExpression iterable, BooleanExpression predicateExpression )
+ public static CollectionExpression filter( Identifier name, CollectionExpression iterable,
+ BooleanExpression predicateExpression )
{
Query.checkNull( name, "Name" );
Query.checkNull( iterable, "Iterable" );
@@ -1519,48 +1550,51 @@ public static CollectionExpression filter( Identifier name, CollectionExpression
filter.name = name;
filter.iterable = iterable;
filter.predicate = predicateExpression;
- return new Value( filter);
+ return new Value( filter );
}
/**
* Declare a tail expression. Corresponds to:
* <pre>
* tail(collectionExpression)
* </pre>
+ *
* @param collectionExpression
* @return
*/
- public static CollectionExpression tail(CollectionExpression collectionExpression)
+ public static CollectionExpression tail( CollectionExpression collectionExpression )
{
checkNull( collectionExpression, "Expression" );
- return new Value( new FunctionExpression("tail", collectionExpression));
+ return new Value( new FunctionExpression( "tail", collectionExpression ) );
}
/**
* Declare a range expression. Corresponds to:
* <pre>
* range(start,end)
* </pre>
+ *
* @param start
* @param end
* @return
*/
- public static CollectionExpression range(Number start, Number end)
+ public static CollectionExpression range( Number start, Number end )
{
- return range( literal( start ), literal( end), null );
+ return range( literal( start ), literal( end ), null );
}
/**
* Declare a range expression. Corresponds to:
* <pre>
* range(start,end,step)
* </pre>
+ *
* @param start
* @param end
* @param step
* @return
*/
- public static CollectionExpression range(Number start, Number end, Number step)
+ public static CollectionExpression range( Number start, Number end, Number step )
{
return range( literal( start ), literal( end ), literal( step ) );
}
@@ -1570,11 +1604,12 @@ public static CollectionExpression range(Number start, Number end, Number step)
* <pre>
* range(start,end)
* </pre>
+ *
* @param start
* @param end
* @return
*/
- public static CollectionExpression range(NumericExpression start, NumericExpression end)
+ public static CollectionExpression range( NumericExpression start, NumericExpression end )
{
return range( start, end, null );
}
@@ -1584,30 +1619,36 @@ public static CollectionExpression range(NumericExpression start, NumericExpress
* <pre>
* range(start,end,step)
* </pre>
+ *
* @param start
* @param end
* @param step
* @return
*/
- public static CollectionExpression range(NumericExpression start, NumericExpression end, NumericExpression step)
+ public static CollectionExpression range( NumericExpression start, NumericExpression end, NumericExpression step )
{
- if (step == null)
+ if ( step == null )
+ {
return new Value( new FunctionExpression( "range", new Expressions( new Expression[]{start, end} ) ) );
+ }
else
- return new Value( new FunctionExpression( "range", new Expressions( new Expression[]{start, end, step} ) ) );
+ {
+ return new Value( new FunctionExpression( "range", new Expressions( new Expression[]{start, end,
+ step} ) ) );
+ }
}
// Mathematical expressions
+
/**
* Declare extra parentheses. This can be useful to ensure that operators are performed in the order you desire.
- *
+ * <p/>
* Corresponds to:
* <pre>
* (numericExpression)
* </pre>
- *
*/
- public static NumericExpression p(NumericExpression numericExpression)
+ public static NumericExpression p( NumericExpression numericExpression )
{
return new Value( new FunctionExpression( "", numericExpression ) );
}
@@ -1621,9 +1662,9 @@ public static NumericExpression p(NumericExpression numericExpression)
* @param numericalExpression
* @return
*/
- public static NumericExpression abs(Number numericalExpression)
+ public static NumericExpression abs( Number numericalExpression )
{
- return abs( literal( numericalExpression ));
+ return abs( literal( numericalExpression ) );
}
/**
@@ -1635,9 +1676,9 @@ public static NumericExpression abs(Number numericalExpression)
* @param numericalExpression
* @return
*/
- public static NumericExpression abs(NumericExpression numericalExpression)
+ public static NumericExpression abs( NumericExpression numericalExpression )
{
- return new Value(new FunctionExpression("abs", numericalExpression));
+ return new Value( new FunctionExpression( "abs", numericalExpression ) );
}
/**
@@ -1649,9 +1690,9 @@ public static NumericExpression abs(NumericExpression numericalExpression)
* @param numericalExpression
* @return
*/
- public static NumericExpression round(Number numericalExpression)
+ public static NumericExpression round( Number numericalExpression )
{
- return round( literal( numericalExpression) );
+ return round( literal( numericalExpression ) );
}
/**
@@ -1663,9 +1704,9 @@ public static NumericExpression round(Number numericalExpression)
* @param numericalExpression
* @return
*/
- public static NumericExpression round(NumericExpression numericalExpression)
+ public static NumericExpression round( NumericExpression numericalExpression )
{
- return new Value( new FunctionExpression("round", numericalExpression));
+ return new Value( new FunctionExpression( "round", numericalExpression ) );
}
/**
@@ -1677,7 +1718,7 @@ public static NumericExpression round(NumericExpression numericalExpression)
* @param numericalExpression
* @return
*/
- public static NumericExpression sqrt(Number numericalExpression)
+ public static NumericExpression sqrt( Number numericalExpression )
{
return sqrt( literal( numericalExpression ) );
}
@@ -1691,9 +1732,9 @@ public static NumericExpression sqrt(Number numericalExpression)
* @param numericalExpression
* @return
*/
- public static NumericExpression sqrt(NumericExpression numericalExpression)
+ public static NumericExpression sqrt( NumericExpression numericalExpression )
{
- return new Value( new FunctionExpression("sqrt", numericalExpression));
+ return new Value( new FunctionExpression( "sqrt", numericalExpression ) );
}
/**
@@ -1705,7 +1746,7 @@ public static NumericExpression sqrt(NumericExpression numericalExpression)
* @param numericalExpression
* @return
*/
- public static NumericExpression sign(Number numericalExpression)
+ public static NumericExpression sign( Number numericalExpression )
{
return sign( literal( numericalExpression ) );
}
@@ -1719,9 +1760,9 @@ public static NumericExpression sign(Number numericalExpression)
* @param numericalExpression
* @return
*/
- public static NumericExpression sign(NumericExpression numericalExpression)
+ public static NumericExpression sign( NumericExpression numericalExpression )
{
- return new Value( new FunctionExpression("sign", numericalExpression));
+ return new Value( new FunctionExpression( "sign", numericalExpression ) );
}
@Override
@@ -1732,10 +1773,11 @@ public String toString()
// Grammar
protected class Grammar
- implements StartNext, With, WithNext, Create, Set, Delete, Relate, UpdateNext, Match, ReturnNext, OrderBy, Skip, Limit, Execute
+ implements StartNext, With, WithNext, Create, Set, Delete, Relate, UpdateNext, Match, ReturnNext, OrderBy,
+ Skip, Limit, Execute
{
// With ---------------------------------------------------------
- public WithNext with(Expression... withExpressions)
+ public WithNext with( Expression... withExpressions )
{
query.add( new WithClause( Arrays.asList( withExpressions ) ) );
@@ -1745,7 +1787,7 @@ public WithNext with(Expression... withExpressions)
@Override
public WithNext with( Iterable<Expression> withExpressions )
{
- query.add( new WithClause( withExpressions ) ) ;
+ query.add( new WithClause( withExpressions ) );
return this;
}
@@ -1768,20 +1810,19 @@ public UpdateNext create( Iterable<PathExpression> paths )
}
-
// Set ----------------------------------------------------------
@Override
public UpdateNext set( SetProperty... setProperties )
{
- query.add(new SetClause( Arrays.asList( setProperties ) ));
+ query.add( new SetClause( Arrays.asList( setProperties ) ) );
return this;
}
@Override
public UpdateNext set( Iterable<SetProperty> setProperties )
{
- query.add(new SetClause( setProperties ) );
+ query.add( new SetClause( setProperties ) );
return this;
}
@@ -1790,7 +1831,7 @@ public UpdateNext set( Iterable<SetProperty> setProperties )
@Override
public UpdateNext delete( ReferenceExpression... expressions )
{
- query.add( new DeleteClause( Arrays.asList( expressions ) ));
+ query.add( new DeleteClause( Arrays.asList( expressions ) ) );
return this;
}
@@ -1807,15 +1848,15 @@ public UpdateNext delete( Iterable<ReferenceExpression> expressions )
@Override
public UpdateNext relate( PathExpression... expressions )
{
- query.add( new RelateClause(Arrays.asList( expressions )) );
+ query.add( new RelateClause( Arrays.asList( expressions ) ) );
return this;
}
@Override
public UpdateNext relate( Iterable<PathExpression> expressions )
{
- query.add( new RelateClause(expressions ));
+ query.add( new RelateClause( expressions ) );
return this;
}
@@ -1853,9 +1894,9 @@ public Match match( PathExpression... expressions )
}
@Override
- public Match match(Iterable<PathExpression> expressions)
+ public Match match( Iterable<PathExpression> expressions )
{
- query.add( new MatchClause(expressions) );
+ query.add( new MatchClause( expressions ) );
return this;
}
@@ -1864,22 +1905,22 @@ public Match match(Iterable<PathExpression> expressions)
public Where where( BooleanExpression expression )
{
Query.checkNull( expression, "Expression" );
- query.add( new WhereClause(expression) );
+ query.add( new WhereClause( expression ) );
return this;
}
// Return -------------------------------------------------------
@Override
public ReturnNext returns( Expression... returnExpressions )
{
- query.add( new ReturnClause(Arrays.asList( returnExpressions) ));
+ query.add( new ReturnClause( Arrays.asList( returnExpressions ) ) );
return this;
}
@Override
- public ReturnNext returns(Iterable<Expression> returnExpressions)
+ public ReturnNext returns( Iterable<Expression> returnExpressions )
{
- query.add( new ReturnClause(returnExpressions ));
+ query.add( new ReturnClause( returnExpressions ) );
return this;
}
@@ -1892,7 +1933,7 @@ public OrderBy orderBy( Expression... orderByExpressions )
}
@Override
- public OrderBy orderBy(Iterable<Expression> orderByExpressions)
+ public OrderBy orderBy( Iterable<Expression> orderByExpressions )
{
query.add( new OrderByClause( orderByExpressions ) );
return this;
@@ -1902,7 +1943,7 @@ public OrderBy orderBy(Iterable<Expression> orderByExpressions)
@Override
public Limit skip( int skip )
{
- if( skip < 0 )
+ if ( skip < 0 )
{
throw new IllegalArgumentException( "Skip may not be below zero" );
}
@@ -1915,7 +1956,7 @@ public Limit skip( int skip )
@Override
public Execute limit( int limit )
{
- if( limit < 0 )
+ if ( limit < 0 )
{
throw new IllegalArgumentException( "Limit may not be below zero" );
}
@@ -1938,16 +1979,16 @@ public Query toQuery()
}
@Override
- public ExecuteWithParameters parameter(String name, Object value)
+ public ExecuteWithParameters parameter( String name, Object value )
{
- ExecuteWithParams withParams = new ExecuteWithParams(query);
- return withParams.parameter(name, value);
+ ExecuteWithParams withParams = new ExecuteWithParams( query );
+ return withParams.parameter( name, value );
}
@Override
- public ExecuteWithParameters parameters(Map<String,Object> parameters)
+ public ExecuteWithParameters parameters( Map<String, Object> parameters )
{
- ExecuteWithParams withParams = new ExecuteWithParams(query);
+ ExecuteWithParams withParams = new ExecuteWithParams( query );
withParams.getParameters().putAll( parameters );
return withParams;
}
@@ -1960,12 +2001,12 @@ public String toString()
}
protected class ExecuteWithParams
- implements ExecuteWithParameters
+ implements ExecuteWithParameters
{
private Query query;
private Map<String, Object> parameters = new HashMap<String, Object>();
- public ExecuteWithParams(Query query)
+ public ExecuteWithParams( Query query )
{
this.query = query;
}
@@ -1982,9 +2023,9 @@ public Query toQuery()
}
@Override
- public ExecuteWithParameters parameter(String name, Object value)
+ public ExecuteWithParameters parameter( String name, Object value )
{
- parameters.put(name, value);
+ parameters.put( name, value );
return this;
}
@@ -1996,9 +2037,9 @@ public ExecuteWithParameters parameters( Map<String, Object> parameters )
}
@Override
- public void asString(StringBuilder builder)
+ public void asString( StringBuilder builder )
{
- query.asString(builder);
+ query.asString( builder );
}
@Override
@@ -2010,7 +2051,7 @@ public String toString()
public static class And
- extends Value
+ extends Value
{
public And( BooleanExpression[] value )
{
@@ -2022,24 +2063,29 @@ public void asString( StringBuilder builder )
{
Expressions expressions = (Expressions) value;
- for( int i = 0; i < expressions.expressions.length; i++ )
+ for ( int i = 0; i < expressions.expressions.length; i++ )
{
- Expression expression = expressions.expressions[ i ];
- if (i > 0)
+ Expression expression = expressions.expressions[i];
+ if ( i > 0 )
+ {
builder.append( " and " );
- if (expression instanceof And || expression instanceof Or)
+ }
+ if ( expression instanceof And || expression instanceof Or )
{
builder.append( '(' );
expression.asString( builder );
builder.append( ')' );
- } else
+ }
+ else
+ {
expression.asString( builder );
+ }
}
}
}
public static class Or
- extends Value
+ extends Value
{
public Or( BooleanExpression[] value )
{
@@ -2051,18 +2097,23 @@ public void asString( StringBuilder builder )
{
Expressions expressions = (Expressions) value;
- for( int i = 0; i < expressions.expressions.length; i++ )
+ for ( int i = 0; i < expressions.expressions.length; i++ )
{
- Expression expression = expressions.expressions[ i ];
- if (i > 0)
+ Expression expression = expressions.expressions[i];
+ if ( i > 0 )
+ {
builder.append( " or " );
- if (expression instanceof And)
+ }
+ if ( expression instanceof And )
{
builder.append( '(' );
expression.asString( builder );
builder.append( ')' );
- } else
+ }
+ else
+ {
expression.asString( builder );
+ }
}
}
}
View
51 src/main/java/org/neo4j/cypherdsl/Identifier.java
@@ -20,35 +20,36 @@
package org.neo4j.cypherdsl;
+import static org.neo4j.cypherdsl.CypherQuery.identifier;
+import static org.neo4j.cypherdsl.query.Query.checkNull;
+
import java.util.regex.Pattern;
+
import org.neo4j.cypherdsl.expression.NumericExpression;
import org.neo4j.cypherdsl.expression.ReferenceExpression;
import org.neo4j.cypherdsl.expression.StringExpression;
import org.neo4j.cypherdsl.query.AbstractExpression;
import org.neo4j.cypherdsl.query.Value;
-import static org.neo4j.cypherdsl.CypherQuery.*;
-import static org.neo4j.cypherdsl.query.Query.*;
-
/**
* Represents an identifier. If the identifier is a node or relationship,
* then you can use the property() method to get a representation of individual properties.
*/
public class Identifier
- extends Value
- implements ReferenceExpression
+ extends Value
+ implements ReferenceExpression
{
private static Pattern simpleName = Pattern.compile( "\\p{Alpha}\\w*" );
Identifier( String name )
{
- super( new IdentifierExpression(name) );
+ super( new IdentifierExpression( name ) );
}
/**
* If this identifier represents a node or relationship,
* then you can use this method to denote a property.
- *
+ * <p/>
* Corresponds to:
* <pre>
* id.name
@@ -57,15 +58,15 @@
* @param name
* @return
*/
- public Property property(String name)
+ public Property property( String name )
{
return property( identifier( name ) );
}
/**
* If this identifier represents a node or relationship,
* then you can use this method to denote a property.
- *
+ * <p/>
* Corresponds to:
* <pre>
* id.name
@@ -74,16 +75,16 @@ public Property property(String name)
* @param name
* @return
*/
- public Property property(Identifier name)
+ public Property property( Identifier name )
{
checkNull( name, "Name" );
- return new Property(this, name);
+ return new Property( this, name );
}
/**
* If this identifier represents a node or relationship,
* then you can use this method to denote a string property.
- *
+ * <p/>
* Corresponds to:
* <pre>
* id.name
@@ -92,15 +93,15 @@ public Property property(Identifier name)
* @param name
* @return
*/
- public StringExpression string(String name)
+ public StringExpression string( String name )
{
return string( identifier( name ) );
}
/**
* If this identifier represents a node or relationship,
* then you can use this method to denote a string property.
- *
+ * <p/>
* Corresponds to:
* <pre>
* id.name
@@ -109,16 +110,16 @@ public StringExpression string(String name)
* @param name
* @return
*/
- public StringExpression string(Identifier name)
+ public StringExpression string( Identifier name )
{
checkNull( name, "Name" );
- return new Property(this, name);
+ return new Property( this, name );
}
/**
* If this identifier represents a node or relationship,
* then you can use this method to denote a numeric property.
- *
+ * <p/>
* Corresponds to:
* <pre>
* id.name
@@ -127,15 +128,15 @@ public StringExpression string(Identifier name)
* @param name
* @return
*/
- public NumericExpression number(String name)
+ public NumericExpression number( String name )
{
return number( identifier( name ) );
}
/**
* If this identifier represents a node or relationship,
* then you can use this method to denote a numeric property.
- *
+ * <p/>
* Corresponds to:
* <pre>
* id.name
@@ -144,14 +145,14 @@ public NumericExpression number(String name)
* @param name
* @return
*/
- public NumericExpression number(Identifier name)
+ public NumericExpression number( Identifier name )
{
checkNull( name, "Name" );
- return new Property(this, name);
+ return new Property( this, name );
}
private static class IdentifierExpression
- extends AbstractExpression
+ extends AbstractExpression
{
private String name;
@@ -162,10 +163,14 @@ private IdentifierExpression( String name )
public void asString( StringBuilder builder )
{
- if (simpleName.matcher( name ).matches())
+ if ( simpleName.matcher( name ).matches() )
+ {
builder.append( name );
+ }
else
+ {
builder.append( '`' ).append( name ).append( '`' );
+ }
}
}
}
View
24 src/main/java/org/neo4j/cypherdsl/Literal.java
@@ -24,18 +24,18 @@
import org.neo4j.cypherdsl.query.Value;
/**
-* Represents a literal value, such as a string or number.
-*/
+ * Represents a literal value, such as a string or number.
+ */
public class Literal
- extends Value
+ extends Value
{
Literal( Object value )
{
- super( new LiteralExpression(value) );
+ super( new LiteralExpression( value ) );
}
private static class LiteralExpression
- extends AbstractExpression
+ extends AbstractExpression
{
public Object value;
@@ -47,15 +47,23 @@ private LiteralExpression( Object value )
@Override
public void asString( StringBuilder builder )
{
- if (value instanceof String)
+ if ( value instanceof String )
{
- if (builder.toString().endsWith( "/" ) || builder.toString().endsWith( "(?i)" )) // -> Regexp with /literal/ or /(?i)literal/
+ if ( builder.toString().endsWith( "/" ) || builder.toString().endsWith( "(?i)" ) ) // -> Regexp with
+ // /literal/ or /(?i)literal/
+ {
builder.append( value.toString().replaceAll( "/", "\\\\/" ) );
+ }
else
- builder.append( "\"" ).append( value.toString().replace( "\\", "\\\\