commonMain.jetbrains.datalore.plot.config.aes.AesOptionConversion.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lets-plot-common Show documentation
Show all versions of lets-plot-common Show documentation
Lets-Plot JVM package without rendering part
/*
* Copyright (c) 2019. JetBrains s.r.o.
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
*/
package jetbrains.datalore.plot.config.aes
import jetbrains.datalore.plot.base.Aes
object AesOptionConversion {
private val CONVERTERS_MAP = TypedOptionConverterMap()
fun getConverter(aes: Aes): (Any?) -> T? {
return CONVERTERS_MAP[aes]
}
fun apply(aes: Aes, optionValue: Any): T? {
val converter = getConverter(aes)
return converter(optionValue)
}
fun applyToList(aes: Aes, optionValues: List<*>): List {
val converter = getConverter(aes)
val result = ArrayList()
for (optionValue in optionValues) {
result.add(converter(optionValue!!))
}
return result
}
/**
* For tests
*/
fun has(aes: Aes<*>): Boolean {
return CONVERTERS_MAP.containsKey(aes)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy