File tree Expand file tree Collapse file tree 3 files changed +19
-15
lines changed
src/main/java/org/mybatis/dynamic/sql Expand file tree Collapse file tree 3 files changed +19
-15
lines changed Original file line number Diff line number Diff line change 1515 */
1616package org .mybatis .dynamic .sql ;
1717
18- public abstract class AbstractNoValueCondition <T > implements VisitableCondition <T > {
18+ import java .util .function .BooleanSupplier ;
19+ import java .util .function .Supplier ;
20+
21+ public abstract class AbstractNoValueCondition <T >
22+ implements VisitableCondition <T > {
1923
2024 @ Override
2125 public <R > R accept (ConditionVisitor <T , R > visitor ) {
2226 return visitor .visit (this );
2327 }
2428
29+ protected <S > S filter (BooleanSupplier booleanSupplier , Supplier <S > empty , S self ) {
30+ if (booleanSupplier .getAsBoolean ()) {
31+ return self ;
32+ } else {
33+ return empty .get ();
34+ }
35+ }
36+
2537 public abstract String renderCondition (String columnName );
2638}
Original file line number Diff line number Diff line change @@ -65,12 +65,8 @@ public <S> IsNotNull<S> when(BooleanSupplier booleanSupplier) {
6565 * render.
6666 */
6767 public <S > IsNotNull <S > filter (BooleanSupplier booleanSupplier ) {
68- if (booleanSupplier .getAsBoolean ()) {
69- @ SuppressWarnings ("unchecked" )
70- IsNotNull <S > self = (IsNotNull <S >) this ;
71- return self ;
72- } else {
73- return IsNotNull .empty ();
74- }
68+ @ SuppressWarnings ("unchecked" )
69+ IsNotNull <S > self = (IsNotNull <S >) this ;
70+ return filter (booleanSupplier , IsNotNull ::empty , self );
7571 }
7672}
Original file line number Diff line number Diff line change @@ -65,12 +65,8 @@ public <S> IsNull<S> when(BooleanSupplier booleanSupplier) {
6565 * render.
6666 */
6767 public <S > IsNull <S > filter (BooleanSupplier booleanSupplier ) {
68- if (booleanSupplier .getAsBoolean ()) {
69- @ SuppressWarnings ("unchecked" )
70- IsNull <S > self = (IsNull <S >) this ;
71- return self ;
72- } else {
73- return IsNull .empty ();
74- }
68+ @ SuppressWarnings ("unchecked" )
69+ IsNull <S > self = (IsNull <S >) this ;
70+ return filter (booleanSupplier , IsNull ::empty , self );
7571 }
7672}
You can’t perform that action at this time.
0 commit comments