File tree Expand file tree Collapse file tree 4 files changed +18
-38
lines changed
main/java/org/mybatis/dynamic/sql Expand file tree Collapse file tree 4 files changed +18
-38
lines changed Original file line number Diff line number Diff line change @@ -34,22 +34,23 @@ protected <S extends AbstractNoValueCondition<?>> S filterSupport(BooleanSupplie
34
34
35
35
public abstract String operator ();
36
36
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
37
+ @ Override
52
38
public FragmentAndParameters renderCondition (RenderingContext renderingContext , BindableColumn <T > leftColumn ) {
53
39
return FragmentAndParameters .fromFragment (operator ());
54
40
}
41
+
42
+ public interface Filterable {
43
+ /**
44
+ * If renderable and the supplier returns true, returns this condition. Else returns a condition that will not
45
+ * render.
46
+ *
47
+ * @param booleanSupplier
48
+ * function that specifies whether the condition should render
49
+ * @param <S>
50
+ * condition type - not used except for compilation compliance
51
+ *
52
+ * @return this condition if renderable and the supplier returns true, otherwise a condition that will not render.
53
+ */
54
+ <S > AbstractNoValueCondition <S > filter (BooleanSupplier booleanSupplier );
55
+ }
55
56
}
Original file line number Diff line number Diff line change 19
19
20
20
import org .mybatis .dynamic .sql .AbstractNoValueCondition ;
21
21
22
- public class IsNotNull <T > extends AbstractNoValueCondition <T > {
22
+ public class IsNotNull <T > extends AbstractNoValueCondition <T > implements AbstractNoValueCondition . Filterable {
23
23
private static final IsNotNull <?> EMPTY = new IsNotNull <>() {
24
24
@ Override
25
25
public boolean isEmpty () {
Original file line number Diff line number Diff line change 19
19
20
20
import org .mybatis .dynamic .sql .AbstractNoValueCondition ;
21
21
22
- public class IsNull <T > extends AbstractNoValueCondition <T > {
22
+ public class IsNull <T > extends AbstractNoValueCondition <T > implements AbstractNoValueCondition . Filterable {
23
23
private static final IsNull <?> EMPTY = new IsNull <>() {
24
24
@ Override
25
25
public boolean isEmpty () {
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 ;
20
19
21
20
import org .jspecify .annotations .NullMarked ;
22
21
import org .mybatis .dynamic .sql .AbstractNoValueCondition ;
23
22
24
23
@ NullMarked
25
24
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
-
39
25
private final String jsonArray ;
40
26
41
27
protected MemberOfCondition (String jsonArray ) {
@@ -47,13 +33,6 @@ public String operator() {
47
33
return "member of(" + jsonArray + ")" ;
48
34
}
49
35
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
-
57
36
public static <T > MemberOfCondition <T > memberOf (String jsonArray ) {
58
37
return new MemberOfCondition <>(jsonArray );
59
38
}
You can’t perform that action at this time.
0 commit comments