@@ -28,7 +28,7 @@ import org.mybatis.dynamic.sql.where.AbstractWhereSupport
28
28
@DslMarker
29
29
annotation class MyBatisDslMarker
30
30
31
- typealias WhereApplier = KotlinBaseBuilder <* , * >.() -> Unit
31
+ typealias WhereApplier = KotlinBaseBuilder <* >.() -> Unit
32
32
33
33
fun WhereApplier.andThen (after : WhereApplier ): WhereApplier = {
34
34
invoke(this )
@@ -37,7 +37,7 @@ fun WhereApplier.andThen(after: WhereApplier): WhereApplier = {
37
37
38
38
@MyBatisDslMarker
39
39
@Suppress(" TooManyFunctions" )
40
- abstract class KotlinBaseBuilder <D : AbstractWhereSupport <* >, B : KotlinBaseBuilder < D , B > > {
40
+ abstract class KotlinBaseBuilder <D : AbstractWhereSupport <* >> {
41
41
fun where (criteria : GroupingCriteriaReceiver ): Unit =
42
42
with (GroupingCriteriaCollector ().apply (criteria)) {
43
43
this @KotlinBaseBuilder.getDsl().where(initialCriterion, subCriteria)
@@ -53,21 +53,18 @@ abstract class KotlinBaseBuilder<D : AbstractWhereSupport<*>, B : KotlinBaseBuil
53
53
this @KotlinBaseBuilder.getDsl().where().or (initialCriterion, subCriteria)
54
54
}
55
55
56
- fun applyWhere (whereApplier : WhereApplier ): B =
57
- self().apply {
58
- whereApplier.invoke(this )
59
- }
56
+ fun applyWhere (whereApplier : WhereApplier ) = whereApplier.invoke(this )
60
57
61
58
@Deprecated(" Deprecated in favor of the new where clause DSL. Update by moving the column and condition " +
62
59
" 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 =
64
61
applyToWhere {
65
62
where(column, condition)
66
63
}
67
64
68
65
@Deprecated(" Deprecated in favor of the new where clause DSL. Update by moving the column and condition " +
69
66
" 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 =
71
68
applyToWhere(subCriteria) { sc ->
72
69
where(column, condition, sc)
73
70
}
@@ -76,28 +73,28 @@ abstract class KotlinBaseBuilder<D : AbstractWhereSupport<*>, B : KotlinBaseBuil
76
73
message = " Deprecated in favor of the new where clause DSL." ,
77
74
replaceWith = ReplaceWith (" where { existsPredicate }" )
78
75
)
79
- fun where (existsPredicate : ExistsPredicate ): B =
76
+ fun where (existsPredicate : ExistsPredicate ): Unit =
80
77
applyToWhere {
81
78
where(existsPredicate)
82
79
}
83
80
84
81
@Deprecated(" Deprecated in favor of the new where clause DSL. Update by moving the exists expression " +
85
82
" into the lambda." )
86
- fun where (existsPredicate : ExistsPredicate , subCriteria : CriteriaReceiver ): B =
83
+ fun where (existsPredicate : ExistsPredicate , subCriteria : CriteriaReceiver ): Unit =
87
84
applyToWhere(subCriteria) { sc ->
88
85
where(existsPredicate, sc)
89
86
}
90
87
91
88
@Deprecated(" Deprecated in favor of the new where clause DSL. Update by moving the column and condition " +
92
89
" 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 =
94
91
applyToWhere {
95
92
and (column, condition)
96
93
}
97
94
98
95
@Deprecated(" Deprecated in favor of the new where clause DSL. Update by moving the column and condition " +
99
96
" 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 =
101
98
applyToWhere(subCriteria) { sc ->
102
99
and (column, condition, sc)
103
100
}
@@ -106,28 +103,28 @@ abstract class KotlinBaseBuilder<D : AbstractWhereSupport<*>, B : KotlinBaseBuil
106
103
message = " Deprecated in favor of the new where clause DSL." ,
107
104
replaceWith = ReplaceWith (" and { existsPredicate }" )
108
105
)
109
- fun and (existsPredicate : ExistsPredicate ): B =
106
+ fun and (existsPredicate : ExistsPredicate ): Unit =
110
107
applyToWhere {
111
108
and (existsPredicate)
112
109
}
113
110
114
111
@Deprecated(" Deprecated in favor of the new where clause DSL. Update by moving the exists expression " +
115
112
" into the lambda." )
116
- fun and (existsPredicate : ExistsPredicate , subCriteria : CriteriaReceiver ): B =
113
+ fun and (existsPredicate : ExistsPredicate , subCriteria : CriteriaReceiver ): Unit =
117
114
applyToWhere(subCriteria) { sc ->
118
115
and (existsPredicate, sc)
119
116
}
120
117
121
118
@Deprecated(" Deprecated in favor of the new where clause DSL. Update by moving the column and condition " +
122
119
" 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 =
124
121
applyToWhere {
125
122
or (column, condition)
126
123
}
127
124
128
125
@Deprecated(" Deprecated in favor of the new where clause DSL. Update by moving the column and condition " +
129
126
" 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 =
131
128
applyToWhere(subCriteria) { sc ->
132
129
or (column, condition, sc)
133
130
}
@@ -136,125 +133,118 @@ abstract class KotlinBaseBuilder<D : AbstractWhereSupport<*>, B : KotlinBaseBuil
136
133
message = " Deprecated in favor of the new where clause DSL." ,
137
134
replaceWith = ReplaceWith (" or { existsPredicate }" )
138
135
)
139
- fun or (existsPredicate : ExistsPredicate ): B =
136
+ fun or (existsPredicate : ExistsPredicate ): Unit =
140
137
applyToWhere {
141
138
or (existsPredicate)
142
139
}
143
140
144
141
@Deprecated(" Deprecated in favor of the new where clause DSL. Update by moving the exists expression " +
145
142
" into the lambda." )
146
- fun or (existsPredicate : ExistsPredicate , subCriteria : CriteriaReceiver ): B =
143
+ fun or (existsPredicate : ExistsPredicate , subCriteria : CriteriaReceiver ): Unit =
147
144
applyToWhere(subCriteria) { sc ->
148
145
or (existsPredicate, sc)
149
146
}
150
147
151
- fun allRows (): B = self()
148
+ fun allRows () {}
152
149
153
- private fun applyToWhere (block : AbstractWhereDSL <* >.() -> Unit ): B {
150
+ private fun applyToWhere (block : AbstractWhereDSL <* >.() -> Unit ) {
154
151
getDsl().where().apply (block)
155
- return self()
156
152
}
157
153
158
154
private fun applyToWhere (
159
155
subCriteria : CriteriaReceiver ,
160
156
block : AbstractWhereDSL <* >.(List <AndOrCriteriaGroup >) -> Unit
161
- ): B {
157
+ ) {
162
158
getDsl().where().block(CriteriaCollector ().apply (subCriteria).criteria)
163
- return self()
164
159
}
165
160
166
- protected abstract fun self (): B
167
-
168
161
protected abstract fun getDsl (): D
169
162
}
170
163
171
164
@Suppress(" TooManyFunctions" )
172
- abstract class KotlinBaseJoiningBuilder <D : AbstractQueryExpressionDSL <* , * >, B : KotlinBaseJoiningBuilder <D , B >> :
173
- KotlinBaseBuilder <D , B >() {
165
+ abstract class KotlinBaseJoiningBuilder <D : AbstractQueryExpressionDSL <* , * >> : KotlinBaseBuilder <D >() {
174
166
175
- fun join (table : SqlTable , joinCriteria : JoinReceiver ): B =
167
+ fun join (table : SqlTable , joinCriteria : JoinReceiver ): Unit =
176
168
applyToDsl(joinCriteria) { jc ->
177
169
join(table, jc.onJoinCriterion, jc.andJoinCriteria)
178
170
}
179
171
180
- fun join (table : SqlTable , alias : String , joinCriteria : JoinReceiver ): B =
172
+ fun join (table : SqlTable , alias : String , joinCriteria : JoinReceiver ): Unit =
181
173
applyToDsl(joinCriteria) { jc ->
182
174
join(table, alias, jc.onJoinCriterion, jc.andJoinCriteria)
183
175
}
184
176
185
177
fun join (
186
178
subQuery : KotlinQualifiedSubQueryBuilder .() -> Unit ,
187
179
joinCriteria : JoinReceiver
188
- ): B =
180
+ ): Unit =
189
181
applyToDsl(subQuery, joinCriteria) { sq, jc ->
190
182
join(sq, sq.correlationName, jc.onJoinCriterion, jc.andJoinCriteria)
191
183
}
192
184
193
- fun fullJoin (table : SqlTable , joinCriteria : JoinReceiver ): B =
185
+ fun fullJoin (table : SqlTable , joinCriteria : JoinReceiver ): Unit =
194
186
applyToDsl(joinCriteria) { jc ->
195
187
fullJoin(table, jc.onJoinCriterion, jc.andJoinCriteria)
196
188
}
197
189
198
- fun fullJoin (table : SqlTable , alias : String , joinCriteria : JoinReceiver ): B =
190
+ fun fullJoin (table : SqlTable , alias : String , joinCriteria : JoinReceiver ): Unit =
199
191
applyToDsl(joinCriteria) { jc ->
200
192
fullJoin(table, alias, jc.onJoinCriterion, jc.andJoinCriteria)
201
193
}
202
194
203
195
fun fullJoin (
204
196
subQuery : KotlinQualifiedSubQueryBuilder .() -> Unit ,
205
197
joinCriteria : JoinReceiver
206
- ): B =
198
+ ): Unit =
207
199
applyToDsl(subQuery, joinCriteria) { sq, jc ->
208
200
fullJoin(sq, sq.correlationName, jc.onJoinCriterion, jc.andJoinCriteria)
209
201
}
210
202
211
- fun leftJoin (table : SqlTable , joinCriteria : JoinReceiver ): B =
203
+ fun leftJoin (table : SqlTable , joinCriteria : JoinReceiver ): Unit =
212
204
applyToDsl(joinCriteria) { jc ->
213
205
leftJoin(table, jc.onJoinCriterion, jc.andJoinCriteria)
214
206
}
215
207
216
- fun leftJoin (table : SqlTable , alias : String , joinCriteria : JoinReceiver ): B =
208
+ fun leftJoin (table : SqlTable , alias : String , joinCriteria : JoinReceiver ): Unit =
217
209
applyToDsl(joinCriteria) { jc ->
218
210
leftJoin(table, alias, jc.onJoinCriterion, jc.andJoinCriteria)
219
211
}
220
212
221
213
fun leftJoin (
222
214
subQuery : KotlinQualifiedSubQueryBuilder .() -> Unit ,
223
215
joinCriteria : JoinReceiver
224
- ): B =
216
+ ): Unit =
225
217
applyToDsl(subQuery, joinCriteria) { sq, jc ->
226
218
leftJoin(sq, sq.correlationName, jc.onJoinCriterion, jc.andJoinCriteria)
227
219
}
228
220
229
- fun rightJoin (table : SqlTable , joinCriteria : JoinReceiver ): B =
221
+ fun rightJoin (table : SqlTable , joinCriteria : JoinReceiver ): Unit =
230
222
applyToDsl(joinCriteria) { jc ->
231
223
rightJoin(table, jc.onJoinCriterion, jc.andJoinCriteria)
232
224
}
233
225
234
- fun rightJoin (table : SqlTable , alias : String , joinCriteria : JoinReceiver ): B =
226
+ fun rightJoin (table : SqlTable , alias : String , joinCriteria : JoinReceiver ): Unit =
235
227
applyToDsl(joinCriteria) { jc ->
236
228
rightJoin(table, alias, jc.onJoinCriterion, jc.andJoinCriteria)
237
229
}
238
230
239
231
fun rightJoin (
240
232
subQuery : KotlinQualifiedSubQueryBuilder .() -> Unit ,
241
233
joinCriteria : JoinReceiver
242
- ): B =
234
+ ): Unit =
243
235
applyToDsl(subQuery, joinCriteria) { sq, jc ->
244
236
rightJoin(sq, sq.correlationName, jc.onJoinCriterion, jc.andJoinCriteria)
245
237
}
246
238
247
- private fun applyToDsl (joinCriteria : JoinReceiver , applyJoin : D .(JoinCollector ) -> Unit ): B {
239
+ private fun applyToDsl (joinCriteria : JoinReceiver , applyJoin : D .(JoinCollector ) -> Unit ) {
248
240
getDsl().applyJoin(JoinCollector ().apply (joinCriteria))
249
- return self()
250
241
}
251
242
252
243
private fun applyToDsl (
253
244
subQuery : KotlinQualifiedSubQueryBuilder .() -> Unit ,
254
245
joinCriteria : JoinReceiver ,
255
246
applyJoin : D .(KotlinQualifiedSubQueryBuilder , JoinCollector ) -> Unit
256
- ): B {
247
+ ) {
257
248
getDsl().applyJoin(KotlinQualifiedSubQueryBuilder ().apply (subQuery), JoinCollector ().apply (joinCriteria))
258
- return self()
259
249
}
260
250
}
0 commit comments