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

commonMain.at.asitplus.jsonpath.JsonPathFunctionExtensionMapRepository.kt Maven / Gradle / Ivy

package at.asitplus.jsonpath

import at.asitplus.jsonpath.core.JsonPathFunctionExtension

internal class JsonPathFunctionExtensionMapRepository(
    private val extensions: MutableMap> = mutableMapOf()
) : JsonPathFunctionExtensionRepository {
    override fun addExtension(
        name: String,
        extension: () -> JsonPathFunctionExtension<*>
    ) {
        extensions[name]?.let {
            throw FunctionExtensionCollisionException(
                "A function extension with the name \"$name\" has already been added: $it"
            )
        }
        extensions[name] = extension()
    }

    override fun getExtension(name: String): JsonPathFunctionExtension<*>? = extensions[name]
    override fun export(): Map> = extensions.toMap()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy