4 files changed +38
-23
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,21 @@ protected <S extends AbstractNoValueCondition<?>> S filterSupport(BooleanSupplie
34
34
35
35
public abstract String operator ();
36
36
37
- @ Override
37
+ /**
38
+ * If renderable and the supplier returns true, returns this condition. Else returns a condition that will not
39
+ * render.
40
+ *
41
+ * @param booleanSupplier
42
+ * function that specifies whether the condition should render
43
+ * @param <S>
44
+ * condition type - not used except for compilation compliance
45
+ *
46
+ * @return this condition if renderable and the supplier returns true, otherwise a condition that will not render.
47
+ */
48
+ public abstract <S > AbstractNoValueCondition <S > filter (BooleanSupplier booleanSupplier );
49
+
50
+
51
+ @ Override
38
52
public FragmentAndParameters renderCondition (RenderingContext renderingContext , BindableColumn <T > leftColumn ) {
39
53
return FragmentAndParameters .fromFragment (operator ());
40
54
}
Original file line number Diff line number Diff line change @@ -42,17 +42,7 @@ public String operator() {
42
42
return "is not null" ; //$NON-NLS-1$
43
43
}
44
44
45
- /**
46
- * If renderable and the supplier returns true, returns this condition. Else returns a condition that will not
47
- * render.
48
- *
49
- * @param booleanSupplier
50
- * function that specifies whether the condition should render
51
- * @param <S>
52
- * condition type - not used except for compilation compliance
53
- *
54
- * @return this condition if renderable and the supplier returns true, otherwise a condition that will not render.
55
- */
45
+ @ Override
56
46
public <S > IsNotNull <S > filter (BooleanSupplier booleanSupplier ) {
57
47
@ SuppressWarnings ("unchecked" )
58
48
IsNotNull <S > self = (IsNotNull <S >) this ;
Original file line number Diff line number Diff line change @@ -42,17 +42,7 @@ public String operator() {
42
42
return "is null" ; //$NON-NLS-1$
43
43
}
44
44
45
- /**
46
- * If renderable and the supplier returns true, returns this condition. Else returns a condition that will not
47
- * render.
48
- *
49
- * @param booleanSupplier
50
- * function that specifies whether the condition should render
51
- * @param <S>
52
- * condition type - not used except for compilation compliance
53
- *
54
- * @return this condition if renderable and the supplier returns true, otherwise a condition that will not render.
55
- */
45
+ @ Override
56
46
public <S > IsNull <S > filter (BooleanSupplier booleanSupplier ) {
57
47
@ SuppressWarnings ("unchecked" )
58
48
IsNull <S > self = (IsNull <S >) this ;
Original file line number Diff line number Diff line change 16
16
package examples .mysql ;
17
17
18
18
import java .util .Objects ;
19
+ import java .util .function .BooleanSupplier ;
19
20
20
21
import org .jspecify .annotations .NullMarked ;
21
22
import org .mybatis .dynamic .sql .AbstractNoValueCondition ;
22
23
23
24
@ NullMarked
24
25
public class MemberOfCondition <T > extends AbstractNoValueCondition <T > {
26
+ private static final MemberOfCondition <?> EMPTY = new MemberOfCondition <>("" ) {
27
+ @ Override
28
+ public boolean isEmpty () {
29
+ return true ;
30
+ }
31
+ };
32
+
33
+ public static <T > MemberOfCondition <T > empty () {
34
+ @ SuppressWarnings ("unchecked" )
35
+ MemberOfCondition <T > t = (MemberOfCondition <T >) EMPTY ;
36
+ return t ;
37
+ }
38
+
25
39
private final String jsonArray ;
26
40
27
41
protected MemberOfCondition (String jsonArray ) {
@@ -33,6 +47,13 @@ public String operator() {
33
47
return "member of(" + jsonArray + ")" ;
34
48
}
35
49
50
+ @ Override
51
+ public <S > MemberOfCondition <S > filter (BooleanSupplier booleanSupplier ) {
52
+ @ SuppressWarnings ("unchecked" )
53
+ MemberOfCondition <S > self = (MemberOfCondition <S >) this ;
54
+ return filterSupport (booleanSupplier , MemberOfCondition ::empty , self );
55
+ }
56
+
36
57
public static <T > MemberOfCondition <T > memberOf (String jsonArray ) {
37
58
return new MemberOfCondition <>(jsonArray );
38
59
}
0 commit comments