@@ -66,26 +66,32 @@ public class Criteria implements CriteriaDefinition {
6666
6767 private final @ Nullable SqlIdentifier column ;
6868 private final @ Nullable Comparator comparator ;
69+ private final @ Nullable ExtendedComparator extendedComparator ;
6970 private final @ Nullable Object value ;
7071 private final boolean ignoreCase ;
7172
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 );
7479 }
7580
7681 private Criteria (@ Nullable Criteria previous , Combinator combinator , List <CriteriaDefinition > group ,
7782 @ 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 );
7984 }
8085
8186 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 ) {
8388
8489 this .previous = previous ;
8590 this .combinator = previous != null && previous .isEmpty () ? Combinator .INITIAL : combinator ;
8691 this .group = group ;
8792 this .column = column ;
8893 this .comparator = comparator ;
94+ this .extendedComparator = extendedComparator ;
8995 this .value = value ;
9096 this .ignoreCase = ignoreCase ;
9197 }
@@ -97,6 +103,7 @@ private Criteria(@Nullable Criteria previous, Combinator combinator, List<Criter
97103 this .group = group ;
98104 this .column = null ;
99105 this .comparator = null ;
106+ this .extendedComparator = null ;
100107 this .value = null ;
101108 this .ignoreCase = false ;
102109 }
@@ -260,7 +267,7 @@ public Criteria or(List<? extends CriteriaDefinition> criteria) {
260267 */
261268 public Criteria ignoreCase (boolean ignoreCase ) {
262269 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 );
264271 }
265272 return this ;
266273 }
@@ -363,6 +370,11 @@ public Comparator getComparator() {
363370 return comparator ;
364371 }
365372
373+ @ Override
374+ public ExtendedComparator getExtendedComparator () {
375+ return extendedComparator ;
376+ }
377+
366378 /**
367379 * @return the comparison value. Can be {@literal null}.
368380 */
@@ -408,12 +420,13 @@ public boolean equals(Object o) {
408420 && Objects .equals (group , criteria .group ) //
409421 && Objects .equals (column , criteria .column ) //
410422 && comparator == criteria .comparator //
423+ && extendedComparator == criteria .extendedComparator //
411424 && Objects .equals (value , criteria .value );
412425 }
413426
414427 @ Override
415428 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 );
417430 }
418431
419432 private void unroll (CriteriaDefinition criteria , StringBuilder stringBuilder ) {
@@ -479,29 +492,35 @@ private void render(CriteriaDefinition criteria, StringBuilder stringBuilder) {
479492 return ;
480493 }
481494
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 {
484500
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 ());
491502
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 ;
497509
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 ;
502515
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+ }
505524 }
506525 }
507526
0 commit comments