@@ -28,7 +28,7 @@ import org.mybatis.dynamic.sql.where.AbstractWhereSupport
2828@DslMarker
2929annotation class MyBatisDslMarker
3030
31- typealias WhereApplier = KotlinBaseBuilder <* , * >.() -> Unit
31+ typealias WhereApplier = KotlinBaseBuilder <* >.() -> Unit
3232
3333fun WhereApplier.andThen (after : WhereApplier ): WhereApplier = {
3434 invoke(this )
@@ -37,7 +37,7 @@ fun WhereApplier.andThen(after: WhereApplier): WhereApplier = {
3737
3838@MyBatisDslMarker
3939@Suppress(" TooManyFunctions" )
40- abstract class KotlinBaseBuilder <D : AbstractWhereSupport <* >, B : KotlinBaseBuilder < D , B > > {
40+ abstract class KotlinBaseBuilder <D : AbstractWhereSupport <* >> {
4141 fun where (criteria : GroupingCriteriaReceiver ): Unit =
4242 with (GroupingCriteriaCollector ().apply (criteria)) {
4343 this @KotlinBaseBuilder.getDsl().where(initialCriterion, subCriteria)
@@ -53,21 +53,18 @@ abstract class KotlinBaseBuilder<D : AbstractWhereSupport<*>, B : KotlinBaseBuil
5353 this @KotlinBaseBuilder.getDsl().where().or (initialCriterion, subCriteria)
5454 }
5555
56- fun applyWhere (whereApplier : WhereApplier ): B =
57- self().apply {
58- whereApplier.invoke(this )
59- }
56+ fun applyWhere (whereApplier : WhereApplier ) = whereApplier.invoke(this )
6057
6158 @Deprecated(" Deprecated in favor of the new where clause DSL. Update by moving the column and condition " +
6259 " into a lambda and rewriting the condition to use an infix function." )
63- fun <T > where (column : BindableColumn <T >, condition : VisitableCondition <T >): B =
60+ fun <T > where (column : BindableColumn <T >, condition : VisitableCondition <T >): Unit =
6461 applyToWhere {
6562 where(column, condition)
6663 }
6764
6865 @Deprecated(" Deprecated in favor of the new where clause DSL. Update by moving the column and condition " +
6966 " inside the lambda and rewriting the condition to use an infix function." )
70- fun <T > where (column : BindableColumn <T >, condition : VisitableCondition <T >, subCriteria : CriteriaReceiver ): B =
67+ fun <T > where (column : BindableColumn <T >, condition : VisitableCondition <T >, subCriteria : CriteriaReceiver ): Unit =
7168 applyToWhere(subCriteria) { sc ->
7269 where(column, condition, sc)
7370 }
@@ -76,28 +73,28 @@ abstract class KotlinBaseBuilder<D : AbstractWhereSupport<*>, B : KotlinBaseBuil
7673 message = " Deprecated in favor of the new where clause DSL." ,
7774 replaceWith = ReplaceWith (" where { existsPredicate }" )
7875 )
79- fun where (existsPredicate : ExistsPredicate ): B =
76+ fun where (existsPredicate : ExistsPredicate ): Unit =
8077 applyToWhere {
8178 where(existsPredicate)
8279 }
8380
8481 @Deprecated(" Deprecated in favor of the new where clause DSL. Update by moving the exists expression " +
8582 " into the lambda." )
86- fun where (existsPredicate : ExistsPredicate , subCriteria : CriteriaReceiver ): B =
83+ fun where (existsPredicate : ExistsPredicate , subCriteria : CriteriaReceiver ): Unit =
8784 applyToWhere(subCriteria) { sc ->
8885 where(existsPredicate, sc)
8986 }
9087
9188 @Deprecated(" Deprecated in favor of the new where clause DSL. Update by moving the column and condition " +
9289 " into a lambda and rewriting the condition to use an infix function." )
93- fun <T > and (column : BindableColumn <T >, condition : VisitableCondition <T >): B =
90+ fun <T > and (column : BindableColumn <T >, condition : VisitableCondition <T >): Unit =
9491 applyToWhere {
9592 and (column, condition)
9693 }
9794
9895 @Deprecated(" Deprecated in favor of the new where clause DSL. Update by moving the column and condition " +
9996 " inside the lambda and rewriting the condition to use an infix function." )
100- fun <T > and (column : BindableColumn <T >, condition : VisitableCondition <T >, subCriteria : CriteriaReceiver ): B =
97+ fun <T > and (column : BindableColumn <T >, condition : VisitableCondition <T >, subCriteria : CriteriaReceiver ): Unit =
10198 applyToWhere(subCriteria) { sc ->
10299 and (column, condition, sc)
103100 }
@@ -106,28 +103,28 @@ abstract class KotlinBaseBuilder<D : AbstractWhereSupport<*>, B : KotlinBaseBuil
106103 message = " Deprecated in favor of the new where clause DSL." ,
107104 replaceWith = ReplaceWith (" and { existsPredicate }" )
108105 )
109- fun and (existsPredicate : ExistsPredicate ): B =
106+ fun and (existsPredicate : ExistsPredicate ): Unit =
110107 applyToWhere {
111108 and (existsPredicate)
112109 }
113110
114111 @Deprecated(" Deprecated in favor of the new where clause DSL. Update by moving the exists expression " +
115112 " into the lambda." )
116- fun and (existsPredicate : ExistsPredicate , subCriteria : CriteriaReceiver ): B =
113+ fun and (existsPredicate : ExistsPredicate , subCriteria : CriteriaReceiver ): Unit =
117114 applyToWhere(subCriteria) { sc ->
118115 and (existsPredicate, sc)
119116 }
120117
121118 @Deprecated(" Deprecated in favor of the new where clause DSL. Update by moving the column and condition " +
122119 " into a lambda and rewriting the condition to use an infix function." )
123- fun <T > or (column : BindableColumn <T >, condition : VisitableCondition <T >): B =
120+ fun <T > or (column : BindableColumn <T >, condition : VisitableCondition <T >): Unit =
124121 applyToWhere {
125122 or (column, condition)
126123 }
127124
128125 @Deprecated(" Deprecated in favor of the new where clause DSL. Update by moving the column and condition " +
129126 " inside the lambda and rewriting the condition to use an infix function." )
130- fun <T > or (column : BindableColumn <T >, condition : VisitableCondition <T >, subCriteria : CriteriaReceiver ): B =
127+ fun <T > or (column : BindableColumn <T >, condition : VisitableCondition <T >, subCriteria : CriteriaReceiver ): Unit =
131128 applyToWhere(subCriteria) { sc ->
132129 or (column, condition, sc)
133130 }
@@ -136,125 +133,118 @@ abstract class KotlinBaseBuilder<D : AbstractWhereSupport<*>, B : KotlinBaseBuil
136133 message = " Deprecated in favor of the new where clause DSL." ,
137134 replaceWith = ReplaceWith (" or { existsPredicate }" )
138135 )
139- fun or (existsPredicate : ExistsPredicate ): B =
136+ fun or (existsPredicate : ExistsPredicate ): Unit =
140137 applyToWhere {
141138 or (existsPredicate)
142139 }
143140
144141 @Deprecated(" Deprecated in favor of the new where clause DSL. Update by moving the exists expression " +
145142 " into the lambda." )
146- fun or (existsPredicate : ExistsPredicate , subCriteria : CriteriaReceiver ): B =
143+ fun or (existsPredicate : ExistsPredicate , subCriteria : CriteriaReceiver ): Unit =
147144 applyToWhere(subCriteria) { sc ->
148145 or (existsPredicate, sc)
149146 }
150147
151- fun allRows (): B = self()
148+ fun allRows () {}
152149
153- private fun applyToWhere (block : AbstractWhereDSL <* >.() -> Unit ): B {
150+ private fun applyToWhere (block : AbstractWhereDSL <* >.() -> Unit ) {
154151 getDsl().where().apply (block)
155- return self()
156152 }
157153
158154 private fun applyToWhere (
159155 subCriteria : CriteriaReceiver ,
160156 block : AbstractWhereDSL <* >.(List <AndOrCriteriaGroup >) -> Unit
161- ): B {
157+ ) {
162158 getDsl().where().block(CriteriaCollector ().apply (subCriteria).criteria)
163- return self()
164159 }
165160
166- protected abstract fun self (): B
167-
168161 protected abstract fun getDsl (): D
169162}
170163
171164@Suppress(" TooManyFunctions" )
172- abstract class KotlinBaseJoiningBuilder <D : AbstractQueryExpressionDSL <* , * >, B : KotlinBaseJoiningBuilder <D , B >> :
173- KotlinBaseBuilder <D , B >() {
165+ abstract class KotlinBaseJoiningBuilder <D : AbstractQueryExpressionDSL <* , * >> : KotlinBaseBuilder <D >() {
174166
175- fun join (table : SqlTable , joinCriteria : JoinReceiver ): B =
167+ fun join (table : SqlTable , joinCriteria : JoinReceiver ): Unit =
176168 applyToDsl(joinCriteria) { jc ->
177169 join(table, jc.onJoinCriterion, jc.andJoinCriteria)
178170 }
179171
180- fun join (table : SqlTable , alias : String , joinCriteria : JoinReceiver ): B =
172+ fun join (table : SqlTable , alias : String , joinCriteria : JoinReceiver ): Unit =
181173 applyToDsl(joinCriteria) { jc ->
182174 join(table, alias, jc.onJoinCriterion, jc.andJoinCriteria)
183175 }
184176
185177 fun join (
186178 subQuery : KotlinQualifiedSubQueryBuilder .() -> Unit ,
187179 joinCriteria : JoinReceiver
188- ): B =
180+ ): Unit =
189181 applyToDsl(subQuery, joinCriteria) { sq, jc ->
190182 join(sq, sq.correlationName, jc.onJoinCriterion, jc.andJoinCriteria)
191183 }
192184
193- fun fullJoin (table : SqlTable , joinCriteria : JoinReceiver ): B =
185+ fun fullJoin (table : SqlTable , joinCriteria : JoinReceiver ): Unit =
194186 applyToDsl(joinCriteria) { jc ->
195187 fullJoin(table, jc.onJoinCriterion, jc.andJoinCriteria)
196188 }
197189
198- fun fullJoin (table : SqlTable , alias : String , joinCriteria : JoinReceiver ): B =
190+ fun fullJoin (table : SqlTable , alias : String , joinCriteria : JoinReceiver ): Unit =
199191 applyToDsl(joinCriteria) { jc ->
200192 fullJoin(table, alias, jc.onJoinCriterion, jc.andJoinCriteria)
201193 }
202194
203195 fun fullJoin (
204196 subQuery : KotlinQualifiedSubQueryBuilder .() -> Unit ,
205197 joinCriteria : JoinReceiver
206- ): B =
198+ ): Unit =
207199 applyToDsl(subQuery, joinCriteria) { sq, jc ->
208200 fullJoin(sq, sq.correlationName, jc.onJoinCriterion, jc.andJoinCriteria)
209201 }
210202
211- fun leftJoin (table : SqlTable , joinCriteria : JoinReceiver ): B =
203+ fun leftJoin (table : SqlTable , joinCriteria : JoinReceiver ): Unit =
212204 applyToDsl(joinCriteria) { jc ->
213205 leftJoin(table, jc.onJoinCriterion, jc.andJoinCriteria)
214206 }
215207
216- fun leftJoin (table : SqlTable , alias : String , joinCriteria : JoinReceiver ): B =
208+ fun leftJoin (table : SqlTable , alias : String , joinCriteria : JoinReceiver ): Unit =
217209 applyToDsl(joinCriteria) { jc ->
218210 leftJoin(table, alias, jc.onJoinCriterion, jc.andJoinCriteria)
219211 }
220212
221213 fun leftJoin (
222214 subQuery : KotlinQualifiedSubQueryBuilder .() -> Unit ,
223215 joinCriteria : JoinReceiver
224- ): B =
216+ ): Unit =
225217 applyToDsl(subQuery, joinCriteria) { sq, jc ->
226218 leftJoin(sq, sq.correlationName, jc.onJoinCriterion, jc.andJoinCriteria)
227219 }
228220
229- fun rightJoin (table : SqlTable , joinCriteria : JoinReceiver ): B =
221+ fun rightJoin (table : SqlTable , joinCriteria : JoinReceiver ): Unit =
230222 applyToDsl(joinCriteria) { jc ->
231223 rightJoin(table, jc.onJoinCriterion, jc.andJoinCriteria)
232224 }
233225
234- fun rightJoin (table : SqlTable , alias : String , joinCriteria : JoinReceiver ): B =
226+ fun rightJoin (table : SqlTable , alias : String , joinCriteria : JoinReceiver ): Unit =
235227 applyToDsl(joinCriteria) { jc ->
236228 rightJoin(table, alias, jc.onJoinCriterion, jc.andJoinCriteria)
237229 }
238230
239231 fun rightJoin (
240232 subQuery : KotlinQualifiedSubQueryBuilder .() -> Unit ,
241233 joinCriteria : JoinReceiver
242- ): B =
234+ ): Unit =
243235 applyToDsl(subQuery, joinCriteria) { sq, jc ->
244236 rightJoin(sq, sq.correlationName, jc.onJoinCriterion, jc.andJoinCriteria)
245237 }
246238
247- private fun applyToDsl (joinCriteria : JoinReceiver , applyJoin : D .(JoinCollector ) -> Unit ): B {
239+ private fun applyToDsl (joinCriteria : JoinReceiver , applyJoin : D .(JoinCollector ) -> Unit ) {
248240 getDsl().applyJoin(JoinCollector ().apply (joinCriteria))
249- return self()
250241 }
251242
252243 private fun applyToDsl (
253244 subQuery : KotlinQualifiedSubQueryBuilder .() -> Unit ,
254245 joinCriteria : JoinReceiver ,
255246 applyJoin : D .(KotlinQualifiedSubQueryBuilder , JoinCollector ) -> Unit
256- ): B {
247+ ) {
257248 getDsl().applyJoin(KotlinQualifiedSubQueryBuilder ().apply (subQuery), JoinCollector ().apply (joinCriteria))
258- return self()
259249 }
260250}
0 commit comments