@@ -20,6 +20,8 @@ import java.time.format.DateTimeFormatter
20
20
import java.util.Locale
21
21
import kotlin.reflect.KProperty
22
22
import kotlin.reflect.KType
23
+ import kotlin.uuid.ExperimentalUuidApi
24
+ import kotlin.uuid.Uuid
23
25
24
26
/* *
25
27
* ### Global Parser Options
@@ -73,6 +75,16 @@ public interface GlobalParserOptions {
73
75
public val nulls: Set <String >
74
76
75
77
public val skipTypes: Set <KType >
78
+
79
+ /* *
80
+ * Whether to allow parsing UUIDs to the experimental [kotlin.uuid.Uuid] type.
81
+ * By default, this is false and UUIDs are not recognized.
82
+ *
83
+ * NOTE: Interacting with a [Uuid][Uuid] in your code might require
84
+ * `@`[OptIn][OptIn]`(`[ExperimentalUuidApi][ExperimentalUuidApi]`::class)`.
85
+ * In notebooks, add `-opt-in=kotlin.uuid.ExperimentalUuidApi` to the compiler arguments.
86
+ */
87
+ public var parseExperimentalUuid: Boolean
76
88
}
77
89
78
90
/* *
@@ -101,6 +113,11 @@ public interface GlobalParserOptions {
101
113
* @param skipTypes a set of types that should be skipped during parsing. Parsing will be attempted for all other types.
102
114
* By default, it's an empty set. To skip all types except a specified one, use [convertTo] instead.
103
115
* @param useFastDoubleParser whether to use [FastDoubleParser], defaults to `true`. Please report any issues you encounter.
116
+ * @param parseExperimentalUuid whether to allow parsing UUIDs to the experimental [kotlin.uuid.Uuid] type.
117
+ * By default, this is false and UUIDs are not recognized.
118
+ * NOTE: Interacting with a [Uuid][Uuid] in your code might require
119
+ * `@`[OptIn][OptIn]`(`[ExperimentalUuidApi][ExperimentalUuidApi]`::class)`.
120
+ * In notebooks, add `-opt-in=kotlin.uuid.ExperimentalUuidApi` to the compiler arguments.
104
121
*/
105
122
public class ParserOptions (
106
123
public val locale : Locale ? = null ,
@@ -110,8 +127,31 @@ public class ParserOptions(
110
127
public val nullStrings : Set <String >? = null ,
111
128
public val skipTypes : Set <KType >? = null ,
112
129
public val useFastDoubleParser : Boolean? = null ,
130
+ public val parseExperimentalUuid : Boolean? = null ,
113
131
) {
114
132
133
+ /* * For binary compatibility. */
134
+ @Deprecated(
135
+ message = PARSER_OPTIONS ,
136
+ level = DeprecationLevel .HIDDEN ,
137
+ )
138
+ public constructor (
139
+ locale: Locale ? = null ,
140
+ dateTimeFormatter: DateTimeFormatter ? = null ,
141
+ dateTimePattern: String? = null ,
142
+ nullStrings: Set <String >? = null ,
143
+ skipTypes: Set <KType >? = null ,
144
+ useFastDoubleParser: Boolean? = null ,
145
+ ) : this (
146
+ locale = locale,
147
+ dateTimeFormatter = dateTimeFormatter,
148
+ dateTimePattern = dateTimePattern,
149
+ nullStrings = nullStrings,
150
+ skipTypes = skipTypes,
151
+ useFastDoubleParser = useFastDoubleParser,
152
+ parseExperimentalUuid = null ,
153
+ )
154
+
115
155
/* * For binary compatibility. */
116
156
@Deprecated(
117
157
message = PARSER_OPTIONS ,
@@ -129,7 +169,31 @@ public class ParserOptions(
129
169
nullStrings = nullStrings,
130
170
skipTypes = null ,
131
171
useFastDoubleParser = null ,
172
+ parseExperimentalUuid = null ,
173
+ )
174
+
175
+ /* * For binary compatibility. */
176
+ @Deprecated(
177
+ message = PARSER_OPTIONS_COPY ,
178
+ level = DeprecationLevel .HIDDEN ,
132
179
)
180
+ public fun copy (
181
+ locale : Locale ? = this.locale,
182
+ dateTimeFormatter : DateTimeFormatter ? = this.dateTimeFormatter,
183
+ dateTimePattern : String? = this.dateTimePattern,
184
+ nullStrings : Set <String >? = this.nullStrings,
185
+ skipTypes : Set <KType >? = this.skipTypes,
186
+ useFastDoubleParser : Boolean? = this.useFastDoubleParser,
187
+ ): ParserOptions =
188
+ ParserOptions (
189
+ locale = locale,
190
+ dateTimeFormatter = dateTimeFormatter,
191
+ dateTimePattern = dateTimePattern,
192
+ nullStrings = nullStrings,
193
+ skipTypes = skipTypes,
194
+ useFastDoubleParser = useFastDoubleParser,
195
+ parseExperimentalUuid = null ,
196
+ )
133
197
134
198
/* * For binary compatibility. */
135
199
@Deprecated(
@@ -149,6 +213,7 @@ public class ParserOptions(
149
213
nullStrings = nullStrings,
150
214
skipTypes = skipTypes,
151
215
useFastDoubleParser = useFastDoubleParser,
216
+ parseExperimentalUuid = null ,
152
217
)
153
218
154
219
internal fun getDateTimeFormatter (): DateTimeFormatter ? =
@@ -166,6 +231,7 @@ public class ParserOptions(
166
231
nullStrings : Set <String >? = this.nullStrings,
167
232
skipTypes : Set <KType >? = this.skipTypes,
168
233
useFastDoubleParser : Boolean? = this.useFastDoubleParser,
234
+ parseExperimentalUuid : Boolean? = this.parseExperimentalUuid,
169
235
): ParserOptions =
170
236
ParserOptions (
171
237
locale = locale,
@@ -174,6 +240,7 @@ public class ParserOptions(
174
240
nullStrings = nullStrings,
175
241
skipTypes = skipTypes,
176
242
useFastDoubleParser = useFastDoubleParser,
243
+ parseExperimentalUuid = parseExperimentalUuid,
177
244
)
178
245
179
246
override fun equals (other : Any? ): Boolean {
@@ -188,6 +255,7 @@ public class ParserOptions(
188
255
if (dateTimePattern != other.dateTimePattern) return false
189
256
if (nullStrings != other.nullStrings) return false
190
257
if (skipTypes != other.skipTypes) return false
258
+ if (parseExperimentalUuid != other.parseExperimentalUuid) return false
191
259
192
260
return true
193
261
}
@@ -199,11 +267,12 @@ public class ParserOptions(
199
267
result = 31 * result + (dateTimePattern?.hashCode() ? : 0 )
200
268
result = 31 * result + (nullStrings?.hashCode() ? : 0 )
201
269
result = 31 * result + (skipTypes?.hashCode() ? : 0 )
270
+ result = 31 * result + (parseExperimentalUuid?.hashCode() ? : 0 )
202
271
return result
203
272
}
204
273
205
274
override fun toString (): String =
206
- " ParserOptions(locale=$locale , dateTimeFormatter=$dateTimeFormatter , dateTimePattern=$dateTimePattern , nullStrings=$nullStrings , skipTypes=$skipTypes , useFastDoubleParser=$useFastDoubleParser )"
275
+ " ParserOptions(locale=$locale , dateTimeFormatter=$dateTimeFormatter , dateTimePattern=$dateTimePattern , nullStrings=$nullStrings , skipTypes=$skipTypes , useFastDoubleParser=$useFastDoubleParser , parseExperimentalUuid= $parseExperimentalUuid )"
207
276
}
208
277
209
278
/* * Tries to parse a column of strings into a column of a different type.
0 commit comments