@@ -84,6 +84,8 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
84
84
85
85
public operator fun String.rangeTo (endInclusive : String ): ColumnSet <* > = toColumnAccessor().rangeTo(endInclusive.toColumnAccessor())
86
86
87
+ public operator fun KProperty <* >.rangeTo (endInclusive : KProperty <* >): ColumnSet <* > = toColumnAccessor().rangeTo(endInclusive.toColumnAccessor())
88
+
87
89
public operator fun AnyColumnReference.rangeTo (endInclusive : AnyColumnReference ): ColumnSet <* > = object : ColumnSet <Any ?> {
88
90
override fun resolve (context : ColumnResolutionContext ): List <ColumnWithPath <Any ?>> {
89
91
val startPath = this @rangeTo.resolveSingle(context)!! .path
@@ -117,18 +119,19 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
117
119
transform { it.flatMap { col -> names.mapNotNull { col.getChild(it) } } }
118
120
}
119
121
122
+ public fun <C > ColumnSet <* >.cols (firstCol : KProperty <C >, vararg otherCols : KProperty <C >): ColumnSet <C > =
123
+ (listOf (firstCol) + otherCols).let { names ->
124
+ transform { it.flatMap { col -> names.mapNotNull { col.getChild(it) } } }
125
+ }
126
+
120
127
public fun ColumnSet <* >.cols (vararg indices : Int ): ColumnSet <Any ?> =
121
128
transform { it.flatMap { it.children().let { children -> indices.map { children[it] } } } }
122
129
123
130
public fun ColumnSet <* >.cols (range : IntRange ): ColumnSet <Any ?> =
124
- transform { it.flatMap { it.children().subList(range.start , range.endInclusive + 1 ) } }
131
+ transform { it.flatMap { it.children().subList(range.first , range.last + 1 ) } }
125
132
126
133
// region select
127
134
128
- public fun <C > ColumnSet<DataRow<C>>.select (vararg columns : String ): ColumnSet <* > = select { columns.toColumns() }
129
-
130
- public fun <C , R > ColumnSet<DataRow<C>>.select (vararg columns : KProperty <R >): ColumnSet <R > = select { columns.toColumns() }
131
-
132
135
public fun <C , R > ColumnSet<DataRow<C>>.select (selector : ColumnsSelector <C , R >): ColumnSet <R > = createColumnSet {
133
136
this @select.resolve(it).flatMap { group ->
134
137
group.asColumnGroup().getColumnsWithPaths(selector).map {
@@ -137,6 +140,12 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
137
140
}
138
141
}
139
142
143
+ public fun <C > ColumnSet<DataRow<C>>.select (vararg columns : String ): ColumnSet <* > = select { columns.toColumns() }
144
+
145
+ public fun <C , R > ColumnSet<DataRow<C>>.select (vararg columns : ColumnReference <R >): ColumnSet <R > = select { columns.toColumns() }
146
+
147
+ public fun <C , R > ColumnSet<DataRow<C>>.select (vararg columns : KProperty <R >): ColumnSet <R > = select { columns.toColumns() }
148
+
140
149
// endregion
141
150
142
151
// endregion
@@ -147,6 +156,8 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
147
156
148
157
public fun String.dfs (predicate : (ColumnWithPath <* >) -> Boolean ): ColumnSet <* > = toColumnAccessor().dfs(predicate)
149
158
159
+ public fun <C > KProperty<C>.dfs (predicate : (ColumnWithPath <* >) -> Boolean ): ColumnSet <* > = toColumnAccessor().dfs(predicate)
160
+
150
161
// endregion
151
162
152
163
// region all
@@ -155,12 +166,16 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
155
166
156
167
public fun String.all (): ColumnSet <* > = toColumnAccessor().transformSingle { it.children() }
157
168
169
+ public fun KProperty <* >.all (): ColumnSet <* > = toColumnAccessor().transformSingle { it.children() }
170
+
158
171
// region allDfs
159
172
160
173
public fun ColumnSet <* >.allDfs (includeGroups : Boolean = false): ColumnSet <Any ?> = if (includeGroups) dfs { true } else dfs { ! it.isColumnGroup() }
161
174
162
175
public fun String.allDfs (includeGroups : Boolean = false): ColumnSet <Any ?> = toColumnAccessor().allDfs(includeGroups)
163
176
177
+ public fun KProperty <* >.allDfs (includeGroups : Boolean = false): ColumnSet <Any ?> = toColumnAccessor().allDfs(includeGroups)
178
+
164
179
// endregion
165
180
166
181
// region allAfter
@@ -179,13 +194,24 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
179
194
180
195
public fun SingleColumn <* >.allAfter (colName : String ): ColumnSet <Any ?> = allAfter(pathOf(colName))
181
196
public fun SingleColumn <* >.allAfter (column : AnyColumnReference ): ColumnSet <Any ?> = allAfter(column.path())
197
+ public fun SingleColumn <* >.allAfter (column : KProperty <* >): ColumnSet <Any ?> = allAfter(column.toColumnAccessor().path())
198
+
199
+ public fun String.allAfter (colPath : ColumnPath ): ColumnSet <Any ?> = toColumnAccessor().allAfter(colPath)
200
+ public fun String.allAfter (colName : String ): ColumnSet <Any ?> = toColumnAccessor().allAfter(colName)
201
+ public fun String.allAfter (column : AnyColumnReference ): ColumnSet <Any ?> = toColumnAccessor().allAfter(column)
202
+ public fun String.allAfter (column : KProperty <* >): ColumnSet <Any ?> = toColumnAccessor().allAfter(column)
203
+
204
+ public fun KProperty <* >.allAfter (colPath : ColumnPath ): ColumnSet <Any ?> = toColumnAccessor().allAfter(colPath)
205
+ public fun KProperty <* >.allAfter (colName : String ): ColumnSet <Any ?> = toColumnAccessor().allAfter(colName)
206
+ public fun KProperty <* >.allAfter (column : AnyColumnReference ): ColumnSet <Any ?> = toColumnAccessor().allAfter(column)
207
+ public fun KProperty <* >.allAfter (column : KProperty <* >): ColumnSet <Any ?> = toColumnAccessor().allAfter(column)
182
208
183
209
// endregion
184
210
185
- // region allSince
211
+ // region allFrom
186
212
187
213
// including current
188
- public fun SingleColumn <* >.allSince (colPath : ColumnPath ): ColumnSet <Any ?> {
214
+ public fun SingleColumn <* >.allFrom (colPath : ColumnPath ): ColumnSet <Any ?> {
189
215
var take = false
190
216
return children {
191
217
if (take) true
@@ -196,8 +222,19 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
196
222
}
197
223
}
198
224
199
- public fun SingleColumn <* >.allSince (colName : String ): ColumnSet <Any ?> = allSince(pathOf(colName))
200
- public fun SingleColumn <* >.allSince (column : AnyColumnReference ): ColumnSet <Any ?> = allSince(column.path())
225
+ public fun SingleColumn <* >.allFrom (colName : String ): ColumnSet <Any ?> = allFrom(pathOf(colName))
226
+ public fun SingleColumn <* >.allFrom (column : AnyColumnReference ): ColumnSet <Any ?> = allFrom(column.path())
227
+ public fun SingleColumn <* >.allFrom (column : KProperty <* >): ColumnSet <Any ?> = allFrom(column.toColumnAccessor().path())
228
+
229
+ public fun String.allFrom (colPath : ColumnPath ): ColumnSet <Any ?> = toColumnAccessor().allFrom(colPath)
230
+ public fun String.allFrom (colName : String ): ColumnSet <Any ?> = toColumnAccessor().allFrom(colName)
231
+ public fun String.allFrom (column : AnyColumnReference ): ColumnSet <Any ?> = toColumnAccessor().allFrom(column)
232
+ public fun String.allFrom (column : KProperty <* >): ColumnSet <Any ?> = toColumnAccessor().allFrom(column)
233
+
234
+ public fun KProperty <* >.allFrom (colPath : ColumnPath ): ColumnSet <Any ?> = toColumnAccessor().allFrom(colPath)
235
+ public fun KProperty <* >.allFrom (colName : String ): ColumnSet <Any ?> = toColumnAccessor().allFrom(colName)
236
+ public fun KProperty <* >.allFrom (column : AnyColumnReference ): ColumnSet <Any ?> = toColumnAccessor().allFrom(column)
237
+ public fun KProperty <* >.allFrom (column : KProperty <* >): ColumnSet <Any ?> = toColumnAccessor().allFrom(column)
201
238
202
239
// endregion
203
240
@@ -217,13 +254,24 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
217
254
218
255
public fun SingleColumn <* >.allBefore (colName : String ): ColumnSet <Any ?> = allBefore(pathOf(colName))
219
256
public fun SingleColumn <* >.allBefore (column : AnyColumnReference ): ColumnSet <Any ?> = allBefore(column.path())
257
+ public fun SingleColumn <* >.allBefore (column : KProperty <* >): ColumnSet <Any ?> = allBefore(column.toColumnAccessor().path())
258
+
259
+ public fun String.allBefore (colPath : ColumnPath ): ColumnSet <Any ?> = toColumnAccessor().allBefore(colPath)
260
+ public fun String.allBefore (colName : String ): ColumnSet <Any ?> = toColumnAccessor().allBefore(colName)
261
+ public fun String.allBefore (column : AnyColumnReference ): ColumnSet <Any ?> = toColumnAccessor().allBefore(column)
262
+ public fun String.allBefore (column : KProperty <* >): ColumnSet <Any ?> = toColumnAccessor().allBefore(column)
263
+
264
+ public fun KProperty <* >.allBefore (colPath : ColumnPath ): ColumnSet <Any ?> = toColumnAccessor().allBefore(colPath)
265
+ public fun KProperty <* >.allBefore (colName : String ): ColumnSet <Any ?> = toColumnAccessor().allBefore(colName)
266
+ public fun KProperty <* >.allBefore (column : AnyColumnReference ): ColumnSet <Any ?> = toColumnAccessor().allBefore(column)
267
+ public fun KProperty <* >.allBefore (column : KProperty <* >): ColumnSet <Any ?> = toColumnAccessor().allBefore(column)
220
268
221
269
// endregion
222
270
223
- // region allUntil
271
+ // region allUpTo
224
272
225
273
// including current
226
- public fun SingleColumn <* >.allUntil (colPath : ColumnPath ): ColumnSet <Any ?> {
274
+ public fun SingleColumn <* >.allUpTo (colPath : ColumnPath ): ColumnSet <Any ?> {
227
275
var take = true
228
276
return children {
229
277
if (! take) false
@@ -234,28 +282,54 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
234
282
}
235
283
}
236
284
237
- public fun SingleColumn <* >.allUntil (colName : String ): ColumnSet <Any ?> = allUntil(pathOf(colName))
238
- public fun SingleColumn <* >.allUntil (column : AnyColumnReference ): ColumnSet <Any ?> = allUntil(column.path())
285
+ public fun SingleColumn <* >.allUpTo (colName : String ): ColumnSet <Any ?> = allUpTo(pathOf(colName))
286
+ public fun SingleColumn <* >.allUpTo (column : AnyColumnReference ): ColumnSet <Any ?> = allUpTo(column.path())
287
+ public fun SingleColumn <* >.allUpTo (column : KProperty <* >): ColumnSet <Any ?> = allUpTo(column.toColumnAccessor().path())
288
+
289
+ public fun String.allUpTo (colPath : ColumnPath ): ColumnSet <Any ?> = toColumnAccessor().allUpTo(colPath)
290
+ public fun String.allUpTo (colName : String ): ColumnSet <Any ?> = toColumnAccessor().allUpTo(colName)
291
+ public fun String.allUpTo (column : AnyColumnReference ): ColumnSet <Any ?> = toColumnAccessor().allUpTo(column)
292
+ public fun String.allUpTo (column : KProperty <* >): ColumnSet <Any ?> = toColumnAccessor().allUpTo(column)
293
+
294
+ public fun KProperty <* >.allUpTo (colPath : ColumnPath ): ColumnSet <Any ?> = toColumnAccessor().allUpTo(colPath)
295
+ public fun KProperty <* >.allUpTo (colName : String ): ColumnSet <Any ?> = toColumnAccessor().allUpTo(colName)
296
+ public fun KProperty <* >.allUpTo (column : AnyColumnReference ): ColumnSet <Any ?> = toColumnAccessor().allUpTo(column)
297
+ public fun KProperty <* >.allUpTo (column : KProperty <* >): ColumnSet <Any ?> = toColumnAccessor().allUpTo(column)
239
298
240
299
// endregion
241
300
242
301
// endregion
243
302
303
+ // region groups
304
+
244
305
public fun SingleColumn <* >.groups (filter : (ColumnGroup <* >) -> Boolean = { true }): ColumnSet <AnyRow > =
245
306
children { it.isColumnGroup() && filter(it.asColumnGroup()) } as ColumnSet <AnyRow >
246
307
247
- public fun <C > ColumnSet<C>.children (predicate : (ColumnWithPath <Any ?>) -> Boolean = { true }): ColumnSet <Any ?> =
308
+ public fun String.groups (filter : (ColumnGroup <* >) -> Boolean = { true }): ColumnSet <AnyRow > =
309
+ toColumnAccessor().groups(filter)
310
+
311
+ public fun KProperty <* >.groups (filter : (ColumnGroup <* >) -> Boolean = { true }): ColumnSet <AnyRow > =
312
+ toColumnAccessor().groups(filter)
313
+
314
+ // endregion
315
+
316
+ // region children
317
+
318
+ public fun ColumnSet <* >.children (predicate : (ColumnWithPath <Any ?>) -> Boolean = { true }): ColumnSet <Any ?> =
248
319
transform { it.flatMap { it.children().filter { predicate(it) } } }
249
320
250
321
public fun ColumnGroupReference.children (): ColumnSet <Any ?> = transformSingle { it.children() }
251
322
323
+ // endregion
324
+
252
325
public operator fun <C > List<DataColumn<C>>.get (range : IntRange ): ColumnSet <C > =
253
326
ColumnsList (subList(range.first, range.last + 1 ))
254
327
255
328
public fun <C > col (property : KProperty <C >): ColumnAccessor <C > = property.toColumnAccessor()
256
329
257
330
public operator fun ColumnSet <* >.get (colName : String ): ColumnSet <Any ?> = transform { it.mapNotNull { it.getChild(colName) } }
258
331
public operator fun <C > ColumnSet <* >.get (column : ColumnReference <C >): ColumnSet <C > = cols(column)
332
+ public operator fun <C > ColumnSet <* >.get (column : KProperty <C >): ColumnSet <C > = cols(column)
259
333
260
334
public fun SingleColumn<AnyRow>.take (n : Int ): ColumnSet <* > = transformSingle { it.children().take(n) }
261
335
public fun SingleColumn<AnyRow>.takeLast (n : Int ): ColumnSet <* > = transformSingle { it.children().takeLast(n) }
@@ -304,9 +378,18 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
304
378
public infix fun String.into (column : KProperty <* >): ColumnReference <Any ?> = toColumnAccessor().into(column.columnName)
305
379
306
380
public infix fun <C > ColumnReference<C>.named (newName : String ): ColumnReference <C > = renamedReference(newName)
307
- public infix fun <C > ColumnReference<C>.named (name : KProperty <* >): ColumnReference <C > = named(name.columnName)
381
+ public infix fun <C > ColumnReference<C>.named (nameFrom : ColumnReference <* >): ColumnReference <C > = named(nameFrom.name)
382
+ public infix fun <C > ColumnReference<C>.named (nameFrom : KProperty <* >): ColumnReference <C > = named(nameFrom.columnName)
308
383
309
384
public infix fun String.named (newName : String ): ColumnReference <Any ?> = toColumnAccessor().named(newName)
385
+ public infix fun String.named (nameFrom : ColumnReference <* >): ColumnReference <Any ?> = toColumnAccessor().named(nameFrom.name)
386
+ public infix fun String.named (nameFrom : KProperty <* >): ColumnReference <Any ?> = toColumnAccessor().named(nameFrom.columnName)
387
+
388
+ public infix fun <C > KProperty<C>.named (newName : String ): ColumnReference <C > = toColumnAccessor().named(newName)
389
+
390
+ public infix fun <C > KProperty<C>.named (nameFrom : ColumnReference <* >): ColumnReference <C > = toColumnAccessor().named(nameFrom.name)
391
+
392
+ public infix fun <C > KProperty<C>.named (nameFrom : KProperty <* >): ColumnReference <C > = toColumnAccessor().named(nameFrom.columnName)
310
393
311
394
// region and
312
395
@@ -346,6 +429,21 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
346
429
// endregion
347
430
348
431
public fun <C > ColumnSet<C>.distinct (): ColumnSet <C > = DistinctColumnSet (this )
432
+
433
+ public fun <C > String.dfsOf (type : KType , predicate : (ColumnWithPath <C >) -> Boolean = { true }): ColumnSet <* > =
434
+ toColumnAccessor().dfsOf(type, predicate)
435
+
436
+ public fun <C > KProperty <* >.dfsOf (type : KType , predicate : (ColumnWithPath <C >) -> Boolean = { true }): ColumnSet <* > =
437
+ toColumnAccessor().dfsOf(type, predicate)
438
+
439
+ public fun String.colsOf (type : KType ): ColumnSet <Any ?> = toColumnAccessor().colsOf(type)
440
+ public fun KProperty <* >.colsOf (type : KType ): ColumnSet <Any ?> = toColumnAccessor().colsOf(type)
441
+
442
+ public fun <C > String.colsOf (type : KType , filter : (DataColumn <C >) -> Boolean ): ColumnSet <Any ?> =
443
+ toColumnAccessor().colsOf(type, filter)
444
+
445
+ public fun <C > KProperty <* >.colsOf (type : KType , filter : (DataColumn <C >) -> Boolean ): ColumnSet <Any ?> =
446
+ toColumnAccessor().colsOf(type, filter)
349
447
}
350
448
351
449
public inline fun <T , reified R > ColumnsSelectionDsl<T>.expr (
@@ -356,7 +454,6 @@ public inline fun <T, reified R> ColumnsSelectionDsl<T>.expr(
356
454
357
455
internal fun <T , C > ColumnsSelector <T , C >.filter (predicate : (ColumnWithPath <C >) -> Boolean ): ColumnsSelector <T , C > =
358
456
{ this @filter(it, it).filter(predicate) }
359
- // internal fun Columns<*>.filter(predicate: (AnyCol) -> Boolean) = transform { it.filter { predicate(it.data) } }
360
457
361
458
internal fun ColumnSet <* >.colsInternal (predicate : (AnyCol ) -> Boolean ) =
362
459
transform { it.flatMap { it.children().filter { predicate(it.data) } } }
0 commit comments