Skip to content

Commit f3e8732

Browse files
cols with default argument deprecation
1 parent c5899ef commit f3e8732

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/cols.kt

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ import org.jetbrains.kotlinx.dataframe.impl.columns.TransformableColumnSet
2121
import org.jetbrains.kotlinx.dataframe.impl.columns.transform
2222
import org.jetbrains.kotlinx.dataframe.impl.columns.transformSingle
2323
import org.jetbrains.kotlinx.dataframe.impl.headPlusArray
24+
import org.jetbrains.kotlinx.dataframe.util.COLS_TO_ALL
25+
import org.jetbrains.kotlinx.dataframe.util.COLS_TO_ALL_COLS
26+
import org.jetbrains.kotlinx.dataframe.util.COLS_TO_ALL_COLS_REPLACE
2427
import org.jetbrains.kotlinx.dataframe.util.DEPRECATED_ACCESS_API
2528
import kotlin.reflect.KProperty
2629

@@ -244,9 +247,13 @@ public interface ColsColumnsSelectionDsl<out _UNUSED> {
244247

245248
/** @include [ColumnSetColsPredicateDocs] */
246249
@Suppress("UNCHECKED_CAST")
247-
public fun <C> ColumnSet<C>.cols(predicate: ColumnFilter<C> = { true }): ColumnSet<C> =
250+
public fun <C> ColumnSet<C>.cols(predicate: ColumnFilter<C>): ColumnSet<C> =
248251
colsInternal(predicate as ColumnFilter<*>).cast()
249252

253+
@Deprecated(COLS_TO_ALL, ReplaceWith(COLS_TO_ALL_COLS_REPLACE), DeprecationLevel.ERROR)
254+
public fun <C> ColumnSet<C>.cols(): ColumnSet<C> =
255+
cols { true }
256+
250257
/** @include [ColumnSetColsPredicateDocs] */
251258
public operator fun <C> ColumnSet<C>.get(predicate: ColumnFilter<C> = { true }): ColumnSet<C> = cols(predicate)
252259

@@ -269,9 +276,13 @@ public interface ColsColumnsSelectionDsl<out _UNUSED> {
269276
private interface ColumnsSelectionDslColsPredicateDocs
270277

271278
/** @include [ColumnsSelectionDslColsPredicateDocs] */
272-
public fun ColumnsSelectionDsl<*>.cols(predicate: ColumnFilter<*> = { true }): ColumnSet<*> =
279+
public fun ColumnsSelectionDsl<*>.cols(predicate: ColumnFilter<*>): ColumnSet<*> =
273280
this.asSingleColumn().colsInternal(predicate)
274281

282+
@Deprecated(COLS_TO_ALL, ReplaceWith(COLS_TO_ALL_COLS_REPLACE), DeprecationLevel.ERROR)
283+
public fun ColumnsSelectionDsl<*>.cols(): ColumnSet<*> =
284+
cols { true }
285+
275286
/** @include [ColumnsSelectionDslColsPredicateDocs] */
276287
public operator fun ColumnsSelectionDsl<*>.get(predicate: ColumnFilter<*> = { true }): ColumnSet<*> =
277288
cols(predicate)
@@ -294,9 +305,13 @@ public interface ColsColumnsSelectionDsl<out _UNUSED> {
294305
private interface SingleColumnAnyRowColsPredicateDocs
295306

296307
/** @include [SingleColumnAnyRowColsPredicateDocs] */
297-
public fun SingleColumn<DataRow<*>>.cols(predicate: ColumnFilter<*> = { true }): ColumnSet<*> =
308+
public fun SingleColumn<DataRow<*>>.cols(predicate: ColumnFilter<*>): ColumnSet<*> =
298309
this.ensureIsColumnGroup().colsInternal(predicate)
299310

311+
@Deprecated(COLS_TO_ALL_COLS, ReplaceWith(COLS_TO_ALL_COLS_REPLACE), DeprecationLevel.ERROR)
312+
public fun SingleColumn<DataRow<*>>.cols(): ColumnSet<*> =
313+
cols { true }
314+
300315
/**
301316
* @include [SingleColumnAnyRowColsPredicateDocs]
302317
*/
@@ -318,7 +333,10 @@ public interface ColsColumnsSelectionDsl<out _UNUSED> {
318333
private interface StringColsPredicateDocs
319334

320335
/** @include [StringColsPredicateDocs] */
321-
public fun String.cols(predicate: ColumnFilter<*> = { true }): ColumnSet<*> = columnGroup(this).cols(predicate)
336+
public fun String.cols(predicate: ColumnFilter<*>): ColumnSet<*> = columnGroup(this).cols(predicate)
337+
338+
@Deprecated(COLS_TO_ALL_COLS, ReplaceWith(COLS_TO_ALL_COLS_REPLACE), DeprecationLevel.ERROR)
339+
public fun String.cols(): ColumnSet<*> = cols { true }
322340

323341
/** @include [StringColsPredicateDocs] */
324342
public operator fun String.get(predicate: ColumnFilter<*> = { true }): ColumnSet<*> = cols(predicate)
@@ -363,7 +381,10 @@ public interface ColsColumnsSelectionDsl<out _UNUSED> {
363381
private interface ColumnPathPredicateDocs
364382

365383
/** @include [ColumnPathPredicateDocs] */
366-
public fun ColumnPath.cols(predicate: ColumnFilter<*> = { true }): ColumnSet<*> = columnGroup(this).cols(predicate)
384+
public fun ColumnPath.cols(predicate: ColumnFilter<*>): ColumnSet<*> = columnGroup(this).cols(predicate)
385+
386+
@Deprecated(COLS_TO_ALL_COLS, ReplaceWith(COLS_TO_ALL_COLS_REPLACE), DeprecationLevel.ERROR)
387+
public fun ColumnPath.cols(): ColumnSet<*> = cols { true }
367388

368389
/** @include [ColumnPathPredicateDocs] */
369390
public operator fun ColumnPath.get(predicate: ColumnFilter<*> = { true }): ColumnSet<*> = cols(predicate)

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/util/deprecationMessages.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,4 +213,10 @@ internal const val ALL_COLS_EXCEPT_REPLACE = "this.allColsExcept { other }"
213213
internal const val ALL_COLS_EXCEPT_REPLACE_VARARG = "this.allColsExcept { others.toColumnSet() }"
214214
internal const val EXCEPT_REPLACE = "this.except { other }"
215215
internal const val EXCEPT_REPLACE_VARARG = "this.except { others.toColumnSet() }"
216+
217+
internal const val COLS_TO_ALL = "This `cols()` overload will be removed in favor of `all()`. $MESSAGE_1_0"
218+
internal const val COLS_TO_ALL_REPLACE = "this.all()"
219+
220+
internal const val COLS_TO_ALL_COLS = "This `cols()` overload will be removed in favor of `allCols()`. $MESSAGE_1_0"
221+
internal const val COLS_TO_ALL_COLS_REPLACE = "this.allCols()"
216222
// endregion

0 commit comments

Comments
 (0)