commonMain.org.jetbrains.letsPlot.intern.Options.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lets-plot-kotlin-kernel Show documentation
Show all versions of lets-plot-kotlin-kernel Show documentation
Lets-Plot Kotlin API without dependencies.
/*
* Copyright (c) 2021. JetBrains s.r.o.
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
*/
package org.jetbrains.letsPlot.intern
import org.jetbrains.letsPlot.intern.standardizing.MapStandardizing
class Options(map: Map) {
companion object {
fun of(pair: Pair) = Options(mapOf(pair))
fun of(vararg pairs: Pair) = Options(mapOf(*pairs))
fun empty() = Options(emptyMap())
}
val map: Map = MapStandardizing.standardize(map)
operator fun plus(other: Options) = Options(this.map + other.map)
fun has(k: String): Boolean {
return map.containsKey(k)
}
fun get(k: String): Any {
return map[k] ?: throw IllegalArgumentException("No such option: '$k'")
}
fun isEmpty() = map.isEmpty()
}