All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.jetbrains.datalore.plot.config.aes.AesOptionConversion.kt Maven / Gradle / Ivy

There is a newer version: 4.5.3-alpha1
Show newest version
/*
 * 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