@@ -20,6 +20,8 @@ import java.time.format.DateTimeFormatter
2020import java.util.Locale
2121import kotlin.reflect.KProperty
2222import kotlin.reflect.KType
23+ import kotlin.uuid.ExperimentalUuidApi
24+ import kotlin.uuid.Uuid
2325
2426/* *
2527 * ### Global Parser Options
@@ -73,6 +75,16 @@ public interface GlobalParserOptions {
7375 public val nulls: Set <String >
7476
7577 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
7688}
7789
7890/* *
@@ -101,6 +113,11 @@ public interface GlobalParserOptions {
101113 * @param skipTypes a set of types that should be skipped during parsing. Parsing will be attempted for all other types.
102114 * By default, it's an empty set. To skip all types except a specified one, use [convertTo] instead.
103115 * @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.
104121 */
105122public class ParserOptions (
106123 public val locale : Locale ? = null ,
@@ -110,8 +127,31 @@ public class ParserOptions(
110127 public val nullStrings : Set <String >? = null ,
111128 public val skipTypes : Set <KType >? = null ,
112129 public val useFastDoubleParser : Boolean? = null ,
130+ public val parseExperimentalUuid : Boolean? = null ,
113131) {
114132
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+
115155 /* * For binary compatibility. */
116156 @Deprecated(
117157 message = PARSER_OPTIONS ,
@@ -129,7 +169,31 @@ public class ParserOptions(
129169 nullStrings = nullStrings,
130170 skipTypes = null ,
131171 useFastDoubleParser = null ,
172+ parseExperimentalUuid = null ,
173+ )
174+
175+ /* * For binary compatibility. */
176+ @Deprecated(
177+ message = PARSER_OPTIONS_COPY ,
178+ level = DeprecationLevel .HIDDEN ,
132179 )
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+ )
133197
134198 /* * For binary compatibility. */
135199 @Deprecated(
@@ -149,6 +213,7 @@ public class ParserOptions(
149213 nullStrings = nullStrings,
150214 skipTypes = skipTypes,
151215 useFastDoubleParser = useFastDoubleParser,
216+ parseExperimentalUuid = null ,
152217 )
153218
154219 internal fun getDateTimeFormatter (): DateTimeFormatter ? =
@@ -166,6 +231,7 @@ public class ParserOptions(
166231 nullStrings : Set <String >? = this.nullStrings,
167232 skipTypes : Set <KType >? = this.skipTypes,
168233 useFastDoubleParser : Boolean? = this.useFastDoubleParser,
234+ parseExperimentalUuid : Boolean? = this.parseExperimentalUuid,
169235 ): ParserOptions =
170236 ParserOptions (
171237 locale = locale,
@@ -174,6 +240,7 @@ public class ParserOptions(
174240 nullStrings = nullStrings,
175241 skipTypes = skipTypes,
176242 useFastDoubleParser = useFastDoubleParser,
243+ parseExperimentalUuid = parseExperimentalUuid,
177244 )
178245
179246 override fun equals (other : Any? ): Boolean {
@@ -188,6 +255,7 @@ public class ParserOptions(
188255 if (dateTimePattern != other.dateTimePattern) return false
189256 if (nullStrings != other.nullStrings) return false
190257 if (skipTypes != other.skipTypes) return false
258+ if (parseExperimentalUuid != other.parseExperimentalUuid) return false
191259
192260 return true
193261 }
@@ -199,11 +267,12 @@ public class ParserOptions(
199267 result = 31 * result + (dateTimePattern?.hashCode() ? : 0 )
200268 result = 31 * result + (nullStrings?.hashCode() ? : 0 )
201269 result = 31 * result + (skipTypes?.hashCode() ? : 0 )
270+ result = 31 * result + (parseExperimentalUuid?.hashCode() ? : 0 )
202271 return result
203272 }
204273
205274 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 )"
207276}
208277
209278/* * Tries to parse a column of strings into a column of a different type.
0 commit comments