@@ -56,15 +56,15 @@ public static <X> Specification<X> equals(String field, String value) {
56
56
);
57
57
}
58
58
59
+ public static <X > Specification <X > notEqual (String field , String value ) {
60
+ return (root , cq , cb ) -> cb .notEqual (getColumnPath (root , field ), value );
61
+ }
62
+
59
63
public static <X > Specification <X > in (String field , List <String > values ) {
60
64
return (root , cq , cb ) ->
61
65
cb .upper (getColumnPath (root , field ).as (String .class )).in (values );
62
66
}
63
67
64
- public static <X > Specification <X > notEqual (String field , String value ) {
65
- return (root , cq , cb ) -> cb .notEqual (getColumnPath (root , field ), value );
66
- }
67
-
68
68
public static <X > Specification <X > contains (String field , String value ) {
69
69
return (root , cq , cb ) -> cb .like (cb .upper (getColumnPath (root , field ).as (String .class )), "%" + EscapeCharacter .DEFAULT .escape (value ).toUpperCase () + "%" , EscapeCharacter .DEFAULT .getEscapeCharacter ());
70
70
}
@@ -151,13 +151,20 @@ private static <X> Specification<X> appendTextFilterToSpecification(Specificatio
151
151
.map (Object ::toString )
152
152
.map (String ::toUpperCase )
153
153
.toList ();
154
- completedSpecification = completedSpecification .and (generateInSpecification (resourceFilter .column (), inValues )
154
+ completedSpecification = completedSpecification .and (
155
+ resourceFilter .type () == ResourceFilterDTO .Type .NOT_EQUAL ?
156
+ not (generateInSpecification (resourceFilter .column (), inValues )) :
157
+ generateInSpecification (resourceFilter .column (), inValues )
155
158
);
156
159
} else if (resourceFilter .value () == null ) {
157
160
// if the value is null, we build an impossible specification (trick to remove later on ?)
158
161
completedSpecification = completedSpecification .and (not (completedSpecification ));
159
162
} else {
160
- completedSpecification = completedSpecification .and (equals (resourceFilter .column (), resourceFilter .value ().toString ()));
163
+ completedSpecification = completedSpecification .and (
164
+ resourceFilter .type () == ResourceFilterDTO .Type .NOT_EQUAL ?
165
+ notEqual (resourceFilter .column (), resourceFilter .value ().toString ()) :
166
+ equals (resourceFilter .column (), resourceFilter .value ().toString ())
167
+ );
161
168
}
162
169
}
163
170
case CONTAINS -> {
0 commit comments