@@ -208,39 +208,17 @@ class QuerydslRsql<E> private constructor(builder: Builder<E>) {
208
208
this .orderSpecifiers = builder.orderSpecifiers
209
209
}
210
210
211
- fun select (select : String? ): BuildBuilder <E > {
212
- this .selectString = select
211
+ fun select (select : String? ): BuildBuilder <E > = BuildBuilder ( this ). apply { this .selectString = select }
212
+ fun select ( vararg expression : Expression < * > ? ): BuildBuilder < E > = BuildBuilder ( this ). apply { this .selectExpressions = expression.filterNotNull().distinct() }
213
213
214
- return BuildBuilder (this )
215
- }
216
-
217
- fun select (vararg expression : Expression <* >? ): BuildBuilder <E > {
218
- this .selectExpressions = expression.filterNotNull().distinct()
219
-
220
- return BuildBuilder (this )
221
- }
222
-
223
- fun from (entityName : String? ): BuildBuilder <E > {
224
- this .entityName = entityName
225
-
226
- return BuildBuilder (this )
227
- }
214
+ fun from (entityName : String? ): BuildBuilder <E > = BuildBuilder (this ).apply { this .entityName = entityName }
215
+ fun from (entityClass : Class <E >? ): BuildBuilder <E > = BuildBuilder (this ).apply { this .entityClass = entityClass }
228
216
229
- fun from (entityClass : Class <E >? ): BuildBuilder <E > {
230
- this .entityClass = entityClass
231
-
232
- return BuildBuilder (this )
233
- }
234
-
235
- fun where (where : String? ): BuildBuilder <E > {
236
- this .where = where
237
-
238
- return BuildBuilder (this )
239
- }
217
+ fun where (where : String? ): BuildBuilder <E > = BuildBuilder (this ).apply { this .where = where }
240
218
241
219
@Suppress(" unused" , " MemberVisibilityCanBePrivate" )
242
220
class BuildBuilder <E >(builder : Builder <E >) : Builder<E>(builder) {
243
- fun globalPredicate (globalPredicate : BooleanExpression ? ): BuildBuilder <E > = this .also { super .globalPredicate = globalPredicate }
221
+ fun globalPredicate (globalPredicate : BooleanExpression ? ): BuildBuilder <E > = this .apply { super .globalPredicate = globalPredicate }
244
222
245
223
@Throws(RsqlException ::class )
246
224
fun build (): QuerydslRsql <E > {
@@ -252,41 +230,37 @@ class QuerydslRsql<E> private constructor(builder: Builder<E>) {
252
230
}
253
231
254
232
fun offset (offset : Int? ): BuildBuilder <E > = offset(offset?.toLong())
255
- fun offset (offset : Long? ): BuildBuilder <E > = this .also { super .offset = offset }
233
+ fun offset (offset : Long? ): BuildBuilder <E > = this .apply { super .offset = offset }
256
234
257
235
fun limit (limit : Int? ): BuildBuilder <E > = limit(limit?.toLong())
258
- fun limit (limit : Long? ): BuildBuilder <E > = this .also { super .limit = limit }
236
+ fun limit (limit : Long? ): BuildBuilder <E > = this .apply { super .limit = limit }
259
237
260
238
fun limit (offset : Int? , limit : Int? ): BuildBuilder <E > = limit(offset?.toLong(), limit?.toLong())
261
- fun limit (offset : Long? , limit : Long? ): BuildBuilder <E > = this .also {
239
+ fun limit (offset : Long? , limit : Long? ): BuildBuilder <E > = this .apply {
262
240
super .offset = offset
263
241
super .limit = limit
264
242
}
265
243
266
244
fun page (pageNumber : Int , pageSize : Int ): BuildBuilder <E > = page(pageNumber.toLong(), pageSize.toLong())
267
245
fun page (pageNumber : Int , pageSize : Long ): BuildBuilder <E > = page(pageNumber.toLong(), pageSize)
268
246
269
- fun page (pageNumber : Long , pageSize : Long ): BuildBuilder <E > = this .also {
247
+ fun page (pageNumber : Long , pageSize : Long ): BuildBuilder <E > = this .apply {
270
248
super .limit = pageSize
271
249
super .offset = pageNumber * pageSize
272
250
}
273
251
274
- fun sort (sort : String? ): BuildBuilder <E > = this .also { super .sort = sort }
275
- fun sort (vararg expression : OrderSpecifier <* >? ): BuildBuilder <E > = this .also { super .orderSpecifiers = expression.filterNotNull().distinct() }
276
- fun sort (orderSpecifiers : List <OrderSpecifier <* >>? ): BuildBuilder <E > = this .also { super .orderSpecifiers = orderSpecifiers }
252
+ fun sort (sort : String? ): BuildBuilder <E > = this .apply { super .sort = sort }
253
+ fun sort (vararg expression : OrderSpecifier <* >? ): BuildBuilder <E > = this .apply { super .orderSpecifiers = expression.filterNotNull().distinct() }
254
+ fun sort (orderSpecifiers : List <OrderSpecifier <* >>? ): BuildBuilder <E > = this .apply { super .orderSpecifiers = orderSpecifiers }
277
255
278
- fun operator (vararg operator : RsqlOperator ): BuildBuilder <E > = this .also { super .rsqlConfig.operators = operator .toList() }
279
- fun operators (operators : List <RsqlOperator >): BuildBuilder <E > = this .also { super .rsqlConfig.operators = operators.toList() }
256
+ fun operator (vararg operator : RsqlOperator ): BuildBuilder <E > = this .apply { super .rsqlConfig.operators = operator .toList() }
257
+ fun operators (operators : List <RsqlOperator >): BuildBuilder <E > = this .apply { super .rsqlConfig.operators = operators.toList() }
280
258
281
- fun fieldTypeHandler (vararg typeHandler : Class <FieldTypeHandler <E >>): BuildBuilder <E > {
282
- return this .also { super .rsqlConfig.addFieldTypeHandler(* typeHandler) }
283
- }
259
+ fun fieldTypeHandler (vararg typeHandler : Class <FieldTypeHandler <E >>): BuildBuilder <E > = this .apply { super .rsqlConfig.addFieldTypeHandler(* typeHandler) }
284
260
285
- fun sortFieldTypeHandler (vararg typeHandler : Class <SortFieldTypeHandler <E >>): BuildBuilder <E > {
286
- return this .also { super .rsqlConfig.addSortFieldTypeHandler(* typeHandler) }
287
- }
261
+ fun sortFieldTypeHandler (vararg typeHandler : Class <SortFieldTypeHandler <E >>): BuildBuilder <E > = this .apply { super .rsqlConfig.addSortFieldTypeHandler(* typeHandler) }
288
262
289
- fun dateFormat (dateFormat : String ): BuildBuilder <E > = this .also { super .rsqlConfig.dateFormat = dateFormat }
263
+ fun dateFormat (dateFormat : String ): BuildBuilder <E > = this .apply { super .rsqlConfig.dateFormat = dateFormat }
290
264
}
291
265
}
292
266
}
0 commit comments