@@ -200,19 +200,12 @@ private ExposesRelationships<?> createRelationshipChain(ExposesRelationships<?>
200
200
relatedNode = relatedNode .named (getNodeName ());
201
201
}
202
202
203
- switch (relationshipDescription .getDirection ()) {
204
- case OUTGOING :
205
- cypherRelationship = cypherRelationship
206
- .relationshipTo (relatedNode , relationshipDescription .getType ());
207
- break ;
208
- case INCOMING :
209
- cypherRelationship = cypherRelationship
210
- .relationshipFrom (relatedNode , relationshipDescription .getType ());
211
- break ;
212
- default :
213
- cypherRelationship = cypherRelationship
214
- .relationshipBetween (relatedNode , relationshipDescription .getType ());
215
- }
203
+ cypherRelationship = switch (relationshipDescription .getDirection ()) {
204
+ case OUTGOING -> cypherRelationship
205
+ .relationshipTo (relatedNode , relationshipDescription .getType ());
206
+ case INCOMING -> cypherRelationship
207
+ .relationshipFrom (relatedNode , relationshipDescription .getType ());
208
+ };
216
209
217
210
if (lastNode || hasTargetNode ) {
218
211
cypherRelationship = ((RelationshipPattern ) cypherRelationship ).named (getRelationshipName ());
@@ -326,73 +319,45 @@ private Condition createImpl(Part part, Iterator<Object> actualParameters) {
326
319
Neo4jPersistentProperty property = path .getRequiredLeafProperty ();
327
320
328
321
boolean ignoreCase = ignoreCase (part );
329
- switch (part .getType ()) {
330
- case AFTER :
331
- case GREATER_THAN :
332
- return toCypherProperty (path , ignoreCase )
333
- .gt (toCypherParameter (nextRequiredParameter (actualParameters , property ), ignoreCase ));
334
- case BEFORE :
335
- case LESS_THAN :
336
- return toCypherProperty (path , ignoreCase )
337
- .lt (toCypherParameter (nextRequiredParameter (actualParameters , property ), ignoreCase ));
338
- case BETWEEN :
339
- return betweenCondition (path , actualParameters , ignoreCase );
340
- case CONTAINING :
341
- return containingCondition (path , property , actualParameters , ignoreCase );
342
- case ENDING_WITH :
343
- return toCypherProperty (path , ignoreCase )
344
- .endsWith (toCypherParameter (nextRequiredParameter (actualParameters , property ), ignoreCase ));
345
- case EXISTS :
346
- return Predicates .exists (toCypherProperty (property ));
347
- case FALSE :
348
- return toCypherProperty (path , ignoreCase ).isFalse ();
349
- case GREATER_THAN_EQUAL :
350
- return toCypherProperty (path , ignoreCase )
351
- .gte (toCypherParameter (nextRequiredParameter (actualParameters , property ), ignoreCase ));
352
- case IN :
353
- return toCypherProperty (path , ignoreCase )
354
- .in (toCypherParameter (nextRequiredParameter (actualParameters , property ), ignoreCase ));
355
- case IS_EMPTY :
356
- return toCypherProperty (path , ignoreCase ).isEmpty ();
357
- case IS_NOT_EMPTY :
358
- return toCypherProperty (path , ignoreCase ).isEmpty ().not ();
359
- case IS_NOT_NULL :
360
- return toCypherProperty (path , ignoreCase ).isNotNull ();
361
- case IS_NULL :
362
- return toCypherProperty (path , ignoreCase ).isNull ();
363
- case LESS_THAN_EQUAL :
364
- return toCypherProperty (path , ignoreCase )
365
- .lte (toCypherParameter (nextRequiredParameter (actualParameters , property ), ignoreCase ));
366
- case LIKE :
367
- return likeCondition (path , nextRequiredParameter (actualParameters , property ).nameOrIndex , ignoreCase );
368
- case NEAR :
369
- return createNearCondition (path , actualParameters );
370
- case NEGATING_SIMPLE_PROPERTY :
371
- return toCypherProperty (path , ignoreCase )
372
- .isNotEqualTo (toCypherParameter (nextRequiredParameter (actualParameters , property ), ignoreCase ));
373
- case NOT_CONTAINING :
374
- return containingCondition (path , property , actualParameters , ignoreCase ).not ();
375
- case NOT_IN :
376
- return toCypherProperty (path , ignoreCase )
377
- .in (toCypherParameter (nextRequiredParameter (actualParameters , property ), ignoreCase )).not ();
378
- case NOT_LIKE :
379
- return likeCondition (path , nextRequiredParameter (actualParameters , property ).nameOrIndex , ignoreCase ).not ();
380
- case SIMPLE_PROPERTY :
381
- return toCypherProperty (path , ignoreCase )
382
- .isEqualTo (toCypherParameter (nextRequiredParameter (actualParameters , property ), ignoreCase ));
383
- case STARTING_WITH :
384
- return toCypherProperty (path , ignoreCase )
385
- .startsWith (toCypherParameter (nextRequiredParameter (actualParameters , property ), ignoreCase ));
386
- case REGEX :
387
- return toCypherProperty (path , ignoreCase )
388
- .matches (toCypherParameter (nextRequiredParameter (actualParameters , property ), ignoreCase ));
389
- case TRUE :
390
- return toCypherProperty (path , ignoreCase ).isTrue ();
391
- case WITHIN :
392
- return createWithinCondition (path , actualParameters );
393
- default :
394
- throw new IllegalArgumentException ("Unsupported part type: " + part .getType ());
395
- }
322
+ return switch (part .getType ()) {
323
+ case AFTER , GREATER_THAN -> toCypherProperty (path , ignoreCase )
324
+ .gt (toCypherParameter (nextRequiredParameter (actualParameters , property ), ignoreCase ));
325
+ case BEFORE , LESS_THAN -> toCypherProperty (path , ignoreCase )
326
+ .lt (toCypherParameter (nextRequiredParameter (actualParameters , property ), ignoreCase ));
327
+ case BETWEEN -> betweenCondition (path , actualParameters , ignoreCase );
328
+ case CONTAINING -> containingCondition (path , property , actualParameters , ignoreCase );
329
+ case ENDING_WITH -> toCypherProperty (path , ignoreCase )
330
+ .endsWith (toCypherParameter (nextRequiredParameter (actualParameters , property ), ignoreCase ));
331
+ case EXISTS -> Predicates .exists (toCypherProperty (property ));
332
+ case FALSE -> toCypherProperty (path , ignoreCase ).isFalse ();
333
+ case GREATER_THAN_EQUAL -> toCypherProperty (path , ignoreCase )
334
+ .gte (toCypherParameter (nextRequiredParameter (actualParameters , property ), ignoreCase ));
335
+ case IN -> toCypherProperty (path , ignoreCase )
336
+ .in (toCypherParameter (nextRequiredParameter (actualParameters , property ), ignoreCase ));
337
+ case IS_EMPTY -> toCypherProperty (path , ignoreCase ).isEmpty ();
338
+ case IS_NOT_EMPTY -> toCypherProperty (path , ignoreCase ).isEmpty ().not ();
339
+ case IS_NOT_NULL -> toCypherProperty (path , ignoreCase ).isNotNull ();
340
+ case IS_NULL -> toCypherProperty (path , ignoreCase ).isNull ();
341
+ case LESS_THAN_EQUAL -> toCypherProperty (path , ignoreCase )
342
+ .lte (toCypherParameter (nextRequiredParameter (actualParameters , property ), ignoreCase ));
343
+ case LIKE -> likeCondition (path , nextRequiredParameter (actualParameters , property ).nameOrIndex , ignoreCase );
344
+ case NEAR -> createNearCondition (path , actualParameters );
345
+ case NEGATING_SIMPLE_PROPERTY -> toCypherProperty (path , ignoreCase )
346
+ .isNotEqualTo (toCypherParameter (nextRequiredParameter (actualParameters , property ), ignoreCase ));
347
+ case NOT_CONTAINING -> containingCondition (path , property , actualParameters , ignoreCase ).not ();
348
+ case NOT_IN -> toCypherProperty (path , ignoreCase )
349
+ .in (toCypherParameter (nextRequiredParameter (actualParameters , property ), ignoreCase )).not ();
350
+ case NOT_LIKE -> likeCondition (path , nextRequiredParameter (actualParameters , property ).nameOrIndex ,
351
+ ignoreCase ).not ();
352
+ case SIMPLE_PROPERTY -> toCypherProperty (path , ignoreCase )
353
+ .isEqualTo (toCypherParameter (nextRequiredParameter (actualParameters , property ), ignoreCase ));
354
+ case STARTING_WITH -> toCypherProperty (path , ignoreCase )
355
+ .startsWith (toCypherParameter (nextRequiredParameter (actualParameters , property ), ignoreCase ));
356
+ case REGEX -> toCypherProperty (path , ignoreCase )
357
+ .matches (toCypherParameter (nextRequiredParameter (actualParameters , property ), ignoreCase ));
358
+ case TRUE -> toCypherProperty (path , ignoreCase ).isTrue ();
359
+ case WITHIN -> createWithinCondition (path , actualParameters );
360
+ };
396
361
}
397
362
398
363
private Condition containingCondition (PersistentPropertyPath <Neo4jPersistentProperty > path ,
@@ -415,16 +380,11 @@ private Condition containingCondition(PersistentPropertyPath<Neo4jPersistentProp
415
380
*/
416
381
boolean ignoreCase (Part part ) {
417
382
418
- switch (part .shouldIgnoreCase ()) {
419
- case ALWAYS :
420
- return true ;
421
- case WHEN_POSSIBLE :
422
- return PartValidator .canIgnoreCase (part );
423
- case NEVER :
424
- return false ;
425
- default :
426
- throw new IllegalArgumentException ("Unsupported option for ignoring case: " + part .shouldIgnoreCase ());
427
- }
383
+ return switch (part .shouldIgnoreCase ()) {
384
+ case ALWAYS -> true ;
385
+ case WHEN_POSSIBLE -> PartValidator .canIgnoreCase (part );
386
+ case NEVER -> false ;
387
+ };
428
388
}
429
389
430
390
private Condition likeCondition (PersistentPropertyPath <Neo4jPersistentProperty > path , String parameterName ,
0 commit comments