Skip to content

Commit fc5033c

Browse files
Automated commit of generated code
1 parent 17e823f commit fc5033c

File tree

5 files changed

+124
-18
lines changed

5 files changed

+124
-18
lines changed

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/annotations/ImportDataSchema.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.jetbrains.kotlinx.dataframe.annotations
22

33
import org.jetbrains.kotlinx.dataframe.api.JsonPath
4-
import org.jetbrains.kotlinx.dataframe.api.KeyValueProperty
4+
import org.jetbrains.kotlinx.dataframe.api.NameValueProperty
55
import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup
66
import org.jetbrains.kotlinx.dataframe.columns.FrameColumn
77
import org.jetbrains.kotlinx.dataframe.documentation.UnifyingNumbers
@@ -78,7 +78,7 @@ public annotation class JsonOptions(
7878
* */
7979
public val typeClashTactic: String = TypeClashTactics.ARRAY_AND_VALUE_COLUMNS,
8080
/**
81-
* List of [JsonPath]s where instead of a [ColumnGroup], a [FrameColumn]<[KeyValueProperty]>
81+
* List of [JsonPath]s where instead of a [ColumnGroup], a [FrameColumn]<[NameValueProperty]>
8282
* will be created.
8383
*
8484
* Example:

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/DataRowApi.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public inline fun <reified R> AnyRow.valuesOf(): List<R> = values().filterIsInst
4141
// region DataSchema
4242
@DataSchema
4343
@RequiredByIntellijPlugin
44-
public data class NameValuePair<V>(val name: String, val value: V)
44+
public data class NameValuePair<V>(override val name: String, override val value: V) : NameValueProperty<V>
4545

4646
// Without these overloads row.transpose().name or row.map { name } won't resolve
4747
public val ColumnsContainer<NameValuePair<*>>.name: DataColumn<String>

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/KeyValueProperty.kt

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
@file:Suppress("UNCHECKED_CAST", "DEPRECATION")
2+
3+
package org.jetbrains.kotlinx.dataframe.api
4+
5+
import org.jetbrains.kotlinx.dataframe.ColumnsScope
6+
import org.jetbrains.kotlinx.dataframe.DataColumn
7+
import org.jetbrains.kotlinx.dataframe.DataRow
8+
import org.jetbrains.kotlinx.dataframe.annotations.ColumnName
9+
import org.jetbrains.kotlinx.dataframe.annotations.DataSchema
10+
import org.jetbrains.kotlinx.dataframe.util.KEY_VALUE_PROPERTY
11+
import org.jetbrains.kotlinx.dataframe.util.KEY_VALUE_PROPERTY_KEY
12+
13+
/** A [DataSchema] interface / class can implement this if it represents a map-like data schema (so name: value). */
14+
@DataSchema
15+
public interface NameValueProperty<T> {
16+
// needs to be explicitly overridden in @DataSchema interface, otherwise extension functions won't generate (TODO)
17+
public val name: String
18+
19+
// needs to be explicitly overridden in @DataSchema interface, otherwise type will be read as `T` and extensions won't generate (TODO)
20+
@ColumnName("value")
21+
public val `value`: T
22+
}
23+
24+
// region Deprecated
25+
26+
/** A [DataSchema] interface / class can implement this if it represents a map-like data schema (so key: value). */
27+
@Deprecated(KEY_VALUE_PROPERTY, ReplaceWith("NameValueProperty<T>"))
28+
public interface KeyValueProperty<T> {
29+
// needs to be explicitly overridden in @DataSchema interface, otherwise extension functions won't generate (TODO)
30+
public val key: String
31+
32+
// needs to be explicitly overridden in @DataSchema interface, otherwise type will be read as `T` and extensions won't generate (TODO)
33+
@ColumnName("value")
34+
public val `value`: T
35+
}
36+
37+
@Deprecated(KEY_VALUE_PROPERTY_KEY, ReplaceWith("name"))
38+
public val ColumnsScope<KeyValueProperty<*>>.key: DataColumn<String>
39+
@JvmName("KeyValueProperty_key")
40+
get() = this["key"].cast()
41+
42+
@Deprecated(KEY_VALUE_PROPERTY_KEY, ReplaceWith("name"))
43+
public val ColumnsScope<KeyValueProperty<*>?>.key: DataColumn<String?>
44+
@JvmName("NullableKeyValueProperty_key")
45+
get() = this["key"].cast()
46+
47+
@Deprecated(KEY_VALUE_PROPERTY_KEY, ReplaceWith("name"))
48+
public val DataRow<KeyValueProperty<*>>.key: String
49+
@JvmName("KeyValueProperty_key")
50+
get() = this["key"] as String
51+
52+
@Deprecated(KEY_VALUE_PROPERTY_KEY, ReplaceWith("name"))
53+
public val DataRow<KeyValueProperty<*>?>.key: String?
54+
@JvmName("NullableKeyValueProperty_key")
55+
get() = this["key"] as String?
56+
57+
/**
58+
* Accesses the 'key' column of this [KeyValueProperty][KeyValueProperty]
59+
* [ColumnsContainer][org.jetbrains.kotlinx.dataframe.ColumnsContainer].
60+
*
61+
* This is a temporary, future-proof, extension property in preparation of the migration from [KeyValueProperty]
62+
* to [NameValueProperty].
63+
*/
64+
public val ColumnsScope<KeyValueProperty<*>>.name: DataColumn<String>
65+
@JvmName("KeyValueProperty_name")
66+
get() = key
67+
68+
/**
69+
* Accesses the 'key' column of this [KeyValueProperty][KeyValueProperty]
70+
* [ColumnsContainer][org.jetbrains.kotlinx.dataframe.ColumnsContainer].
71+
*
72+
* This is a temporary, future-proof, extension property in preparation of the migration from [KeyValueProperty]
73+
* to [NameValueProperty].
74+
*/
75+
public val ColumnsScope<KeyValueProperty<*>?>.name: DataColumn<String?>
76+
@JvmName("NullableKeyValueProperty_name")
77+
get() = key
78+
79+
/**
80+
* Accesses the 'key' value of this [KeyValueProperty][KeyValueProperty]
81+
* [DataRow][DataRow].
82+
*
83+
* This is a temporary, future-proof, extension property in preparation of the migration from [KeyValueProperty]
84+
* to [NameValueProperty].
85+
*/
86+
public val DataRow<KeyValueProperty<*>>.name: String
87+
@JvmName("KeyValueProperty_name")
88+
get() = key
89+
90+
/**
91+
* Accesses the 'key' value of this [KeyValueProperty][KeyValueProperty]
92+
* [DataRow][DataRow].
93+
*
94+
* This is a temporary, future-proof, extension property in preparation of the migration from [KeyValueProperty]
95+
* to [NameValueProperty].
96+
*/
97+
public val DataRow<KeyValueProperty<*>?>.name: String?
98+
@JvmName("NullableKeyValueProperty_name")
99+
get() = key
100+
101+
public val <T : Any?> ColumnsScope<KeyValueProperty<T>>.value: DataColumn<T>
102+
@JvmName("KeyValueProperty_value")
103+
get() = this["value"].cast()
104+
105+
public val <T : Any?> ColumnsScope<KeyValueProperty<T>?>.value: DataColumn<T?>
106+
@JvmName("NullableKeyValueProperty_value")
107+
get() = this["value"].cast()
108+
109+
public val <T : Any?> DataRow<KeyValueProperty<T>>.value: T
110+
@JvmName("KeyValueProperty_value")
111+
get() = this["value"] as T
112+
113+
public val <T : Any?> DataRow<KeyValueProperty<T>?>.value: T?
114+
@JvmName("NullableKeyValueProperty_value")
115+
get() = this["value"] as T?
116+
117+
// endregion

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ internal const val COPY_REPLACE = "columns().toDataFrame().cast()"
263263
internal const val LISTS_TO_DATAFRAME_MIGRATION =
264264
"Function moved from io to api package, and a new `header` parameter is introduced. $MESSAGE_1_1"
265265

266+
internal const val KEY_VALUE_PROPERTY = "Deprecated in favor of NameValueProperty. $MESSAGE_1_1"
267+
internal const val KEY_VALUE_PROPERTY_KEY =
268+
"This column will be renamed to 'name' when KeyValueProperty will be replaced with NameValueProperty. $MESSAGE_1_1"
269+
266270
// endregion
267271

268272
// region keep across releases

0 commit comments

Comments
 (0)