Martin Barth
11/26/2020, 3:19 PM!!
all over the place?
val extractor = when {
config.contains(REGEX) && config.contains(FORMAT) -> FormatAndRegexExtractor(config[REGEX]!!, config[FORMAT]!!)
config.contains(REGEX) && !config.contains(FORMAT) -> NamedCaptureGroupExtractor(config[REGEX]!!)
config.contains(DELIMS) && config.contains(FIELDS) -> DelimiterExtractor(config[DELIMS]!!, config[FIELDS]!!)
else -> throw IllegalArgumentException("can not process this configuration: $config")
}
df
11/26/2020, 3:26 PMconfig[REGEX]
to a local variable before the when. This way the compiler should be able to smart cast itMartin Barth
11/26/2020, 3:39 PM