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

commonMain.org.jetbrains.letsPlot.intern.Options.kt Maven / Gradle / Ivy

There is a newer version: 4.8.0
Show newest version
/*
 * 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()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy