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

io.alkemy.internals.system-properties.kt Maven / Gradle / Ivy

package io.alkemy.internals

inline fun  sysProp(name: String, default: T): T {
    val sysProp = System.getProperty(name) ?: return default
    return when (T::class) {
        String::class -> sysProp as T
        Boolean::class -> sysProp.toBoolean() as T
        Int::class -> sysProp.toInt() as T
        Long::class -> sysProp.toLong() as T
        else -> throw IllegalArgumentException("No convertor for class ${T::class}")
    }
}

inline fun > enumSysProp(name: String, default: T): T {
    val sysProp = System.getProperty(name) ?: return default
    return enumValueOf(sysProp.trim().uppercase())
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy