@@ -66,26 +66,32 @@ public class Criteria implements CriteriaDefinition {
66
66
67
67
private final @ Nullable SqlIdentifier column ;
68
68
private final @ Nullable Comparator comparator ;
69
+ private final @ Nullable ExtendedComparator extendedComparator ;
69
70
private final @ Nullable Object value ;
70
71
private final boolean ignoreCase ;
71
72
72
- public Criteria (SqlIdentifier column , @ Nullable Comparator comparator , @ Nullable Object value ) {
73
- this (null , Combinator .INITIAL , Collections .emptyList (), column , comparator , value , false );
73
+ Criteria (SqlIdentifier column , @ Nullable Comparator comparator , @ Nullable Object value ) {
74
+ this (null , Combinator .INITIAL , Collections .emptyList (), column , comparator , null , value , false );
75
+ }
76
+
77
+ Criteria (SqlIdentifier column , ExtendedComparator extendedComparator , @ Nullable Object value ) {
78
+ this (null , Combinator .INITIAL , Collections .emptyList (), column , null , extendedComparator , value , false );
74
79
}
75
80
76
81
private Criteria (@ Nullable Criteria previous , Combinator combinator , List <CriteriaDefinition > group ,
77
82
@ Nullable SqlIdentifier column , @ Nullable Comparator comparator , @ Nullable Object value ) {
78
- this (previous , combinator , group , column , comparator , value , false );
83
+ this (previous , combinator , group , column , comparator , null , value , false );
79
84
}
80
85
81
86
private Criteria (@ Nullable Criteria previous , Combinator combinator , List <CriteriaDefinition > group ,
82
- @ Nullable SqlIdentifier column , @ Nullable Comparator comparator , @ Nullable Object value , boolean ignoreCase ) {
87
+ @ Nullable SqlIdentifier column , @ Nullable Comparator comparator , @ Nullable ExtendedComparator extendedComparator , @ Nullable Object value , boolean ignoreCase ) {
83
88
84
89
this .previous = previous ;
85
90
this .combinator = previous != null && previous .isEmpty () ? Combinator .INITIAL : combinator ;
86
91
this .group = group ;
87
92
this .column = column ;
88
93
this .comparator = comparator ;
94
+ this .extendedComparator = extendedComparator ;
89
95
this .value = value ;
90
96
this .ignoreCase = ignoreCase ;
91
97
}
@@ -97,6 +103,7 @@ private Criteria(@Nullable Criteria previous, Combinator combinator, List<Criter
97
103
this .group = group ;
98
104
this .column = null ;
99
105
this .comparator = null ;
106
+ this .extendedComparator = null ;
100
107
this .value = null ;
101
108
this .ignoreCase = false ;
102
109
}
@@ -260,7 +267,7 @@ public Criteria or(List<? extends CriteriaDefinition> criteria) {
260
267
*/
261
268
public Criteria ignoreCase (boolean ignoreCase ) {
262
269
if (this .ignoreCase != ignoreCase ) {
263
- return new Criteria (previous , combinator , group , column , comparator , value , ignoreCase );
270
+ return new Criteria (previous , combinator , group , column , comparator , extendedComparator , value , ignoreCase );
264
271
}
265
272
return this ;
266
273
}
@@ -363,6 +370,11 @@ public Comparator getComparator() {
363
370
return comparator ;
364
371
}
365
372
373
+ @ Override
374
+ public ExtendedComparator getExtendedComparator () {
375
+ return extendedComparator ;
376
+ }
377
+
366
378
/**
367
379
* @return the comparison value. Can be {@literal null}.
368
380
*/
@@ -408,12 +420,13 @@ public boolean equals(Object o) {
408
420
&& Objects .equals (group , criteria .group ) //
409
421
&& Objects .equals (column , criteria .column ) //
410
422
&& comparator == criteria .comparator //
423
+ && extendedComparator == criteria .extendedComparator //
411
424
&& Objects .equals (value , criteria .value );
412
425
}
413
426
414
427
@ Override
415
428
public int hashCode () {
416
- return Objects .hash (previous , combinator , group , column , comparator , value , ignoreCase );
429
+ return Objects .hash (previous , combinator , group , column , comparator , extendedComparator , value , ignoreCase );
417
430
}
418
431
419
432
private void unroll (CriteriaDefinition criteria , StringBuilder stringBuilder ) {
@@ -479,29 +492,35 @@ private void render(CriteriaDefinition criteria, StringBuilder stringBuilder) {
479
492
return ;
480
493
}
481
494
482
- stringBuilder .append (criteria .getColumn ().toSql (IdentifierProcessing .NONE )).append (' ' )
483
- .append (criteria .getComparator ().getComparator ());
495
+ stringBuilder .append (criteria .getColumn ().toSql (IdentifierProcessing .NONE )).append (' ' );
496
+
497
+ if (criteria .getExtendedComparator () != null ) {
498
+ stringBuilder .append (criteria .getExtendedComparator ().operator ()).append (' ' ).append (renderValue (criteria .getValue ()));
499
+ } else {
484
500
485
- switch (criteria .getComparator ()) {
486
- case BETWEEN :
487
- case NOT_BETWEEN :
488
- Pair <Object , Object > pair = (Pair <Object , Object >) criteria .getValue ();
489
- stringBuilder .append (' ' ).append (pair .getFirst ()).append (" AND " ).append (pair .getSecond ());
490
- break ;
501
+ stringBuilder .append (criteria .getComparator ().getComparator ());
491
502
492
- case IS_NULL :
493
- case IS_NOT_NULL :
494
- case IS_TRUE :
495
- case IS_FALSE :
496
- break ;
503
+ switch (criteria .getComparator ()) {
504
+ case BETWEEN :
505
+ case NOT_BETWEEN :
506
+ Pair <Object , Object > pair = (Pair <Object , Object >) criteria .getValue ();
507
+ stringBuilder .append (' ' ).append (pair .getFirst ()).append (" AND " ).append (pair .getSecond ());
508
+ break ;
497
509
498
- case IN :
499
- case NOT_IN :
500
- stringBuilder .append (" (" ).append (renderValue (criteria .getValue ())).append (')' );
501
- break ;
510
+ case IS_NULL :
511
+ case IS_NOT_NULL :
512
+ case IS_TRUE :
513
+ case IS_FALSE :
514
+ break ;
502
515
503
- default :
504
- stringBuilder .append (' ' ).append (renderValue (criteria .getValue ()));
516
+ case IN :
517
+ case NOT_IN :
518
+ stringBuilder .append (" (" ).append (renderValue (criteria .getValue ())).append (')' );
519
+ break ;
520
+
521
+ default :
522
+ stringBuilder .append (' ' ).append (renderValue (criteria .getValue ()));
523
+ }
505
524
}
506
525
}
507
526
0 commit comments