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

pl.beone.lib.junit.jupiter.internal.Configuration.kt Maven / Gradle / Ivy

There is a newer version: 1.0.1
Show newest version
package pl.beone.lib.junit.jupiter.internal

import org.testcontainers.shaded.org.apache.commons.lang.text.StrSubstitutor
import pl.beone.lib.typeconverter.internal.castOrConvert
import java.util.*

class Configuration {

    private val baseProperties = Properties().apply {
        load("/docker-extension.properties")
    }
    private val strSubstitutor = StrSubstitutor(baseProperties)

    private fun Properties.load(resourcePath: String) {
        Configuration::class.java.getResourceAsStream(resourcePath)
            ?.let { load(it) }
    }

    fun getProperty(key: String): String =
        strSubstitutor.replace(baseProperties.getProperty(key) ?: throw NoSuchElementException("There is no <$key> element"))

    fun  getProperty(key: String, clazz: Class): T =
        getProperty(key).castOrConvert(clazz)
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy