File tree Expand file tree Collapse file tree 4 files changed +38
-23
lines changed
main/java/org/mybatis/dynamic/sql Expand file tree Collapse file tree 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
3434
3535 public abstract String operator ();
3636
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
3852 public FragmentAndParameters renderCondition (RenderingContext renderingContext , BindableColumn <T > leftColumn ) {
3953 return FragmentAndParameters .fromFragment (operator ());
4054 }
Original file line number Diff line number Diff line change @@ -42,17 +42,7 @@ public String operator() {
4242 return "is not null" ; //$NON-NLS-1$
4343 }
4444
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
5646 public <S > IsNotNull <S > filter (BooleanSupplier booleanSupplier ) {
5747 @ SuppressWarnings ("unchecked" )
5848 IsNotNull <S > self = (IsNotNull <S >) this ;
Original file line number Diff line number Diff line change @@ -42,17 +42,7 @@ public String operator() {
4242 return "is null" ; //$NON-NLS-1$
4343 }
4444
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
5646 public <S > IsNull <S > filter (BooleanSupplier booleanSupplier ) {
5747 @ SuppressWarnings ("unchecked" )
5848 IsNull <S > self = (IsNull <S >) this ;
Original file line number Diff line number Diff line change 1616package examples .mysql ;
1717
1818import java .util .Objects ;
19+ import java .util .function .BooleanSupplier ;
1920
2021import org .jspecify .annotations .NullMarked ;
2122import org .mybatis .dynamic .sql .AbstractNoValueCondition ;
2223
2324@ NullMarked
2425public 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+
2539 private final String jsonArray ;
2640
2741 protected MemberOfCondition (String jsonArray ) {
@@ -33,6 +47,13 @@ public String operator() {
3347 return "member of(" + jsonArray + ")" ;
3448 }
3549
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+
3657 public static <T > MemberOfCondition <T > memberOf (String jsonArray ) {
3758 return new MemberOfCondition <>(jsonArray );
3859 }
You can’t perform that action at this time.
0 commit comments