@@ -54,27 +54,6 @@ protected <R, S extends AbstractSingleValueCondition<R>> S mapSupport(Function<?
54
54
}
55
55
}
56
56
57
- /**
58
- * If renderable and the value matches the predicate, returns this condition. Else returns a condition
59
- * that will not render.
60
- *
61
- * @param predicate predicate applied to the value, if renderable
62
- * @return this condition if renderable and the value matches the predicate, otherwise a condition
63
- * that will not render.
64
- */
65
- public abstract AbstractSingleValueCondition <T > filter (Predicate <? super T > predicate );
66
-
67
- /**
68
- * If renderable, apply the mapping to the value and return a new condition with the new value. Else return a
69
- * condition that will not render (this).
70
- *
71
- * @param mapper a mapping function to apply to the value, if renderable
72
- * @param <R> type of the new condition
73
- * @return a new condition with the result of applying the mapper to the value of this condition,
74
- * if renderable, otherwise a condition that will not render.
75
- */
76
- public abstract <R > AbstractSingleValueCondition <R > map (Function <? super T , ? extends R > mapper );
77
-
78
57
public abstract String operator ();
79
58
80
59
@ Override
@@ -86,4 +65,54 @@ public FragmentAndParameters renderCondition(RenderingContext renderingContext,
86
65
.withParameter (parameterInfo .parameterMapKey (), leftColumn .convertParameterType (value ()))
87
66
.build ();
88
67
}
68
+
69
+ /**
70
+ * Conditions may implement Filterable to add optionality to rendering.
71
+ *
72
+ * <p>If a condition is Filterable, then a user may add a filter to the usage of the condition that makes a decision
73
+ * whether to render the condition at runtime. Conditions that fail the filter will be dropped from the
74
+ * rendered SQL.
75
+ *
76
+ * <p>Implementations of Filterable may call
77
+ * {@link AbstractSingleValueCondition#filterSupport(Predicate, Supplier, AbstractSingleValueCondition)} as
78
+ * a common implementation of the filtering algorithm.
79
+ *
80
+ * @param <T> the Java type related to the database column type
81
+ */
82
+ public interface Filterable <T > {
83
+ /**
84
+ * If renderable and the value matches the predicate, returns this condition. Else returns a condition
85
+ * that will not render.
86
+ *
87
+ * @param predicate predicate applied to the value, if renderable
88
+ * @return this condition if renderable and the value matches the predicate, otherwise a condition
89
+ * that will not render.
90
+ */
91
+ AbstractSingleValueCondition <T > filter (Predicate <? super T > predicate );
92
+ }
93
+
94
+ /**
95
+ * Conditions may implement Mappable to alter condition values or types during rendering.
96
+ *
97
+ * <p>If a condition is Mappable, then a user may add a mapper to the usage of the condition that can alter the
98
+ * values of a condition, or change that datatype.
99
+ *
100
+ * <p>Implementations of Mappable may call
101
+ * {@link AbstractSingleValueCondition#mapSupport(Function, Function, Supplier)} as
102
+ * a common implementation of the mapping algorithm.
103
+ *
104
+ * @param <T> the Java type related to the database column type
105
+ */
106
+ public interface Mappable <T > {
107
+ /**
108
+ * If renderable, apply the mapping to the value and return a new condition with the new value. Else return a
109
+ * condition that will not render (this).
110
+ *
111
+ * @param mapper a mapping function to apply to the value, if renderable
112
+ * @param <R> type of the new condition
113
+ * @return a new condition with the result of applying the mapper to the value of this condition,
114
+ * if renderable, otherwise a condition that will not render.
115
+ */
116
+ <R > AbstractSingleValueCondition <R > map (Function <? super T , ? extends R > mapper );
117
+ }
89
118
}
0 commit comments