io.gitlab.arturbosch.detekt.api.internal.RuleSetConfigProperty.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of detekt-api Show documentation
Show all versions of detekt-api Show documentation
Static code analysis for Kotlin
The newest version!
package io.gitlab.arturbosch.detekt.api.internal
import io.gitlab.arturbosch.detekt.api.Config
import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KProperty
fun ruleSetConfig(defaultValue: T): ReadOnlyProperty> =
RuleSetConfigPropertyDelegate(defaultValue)
private class RuleSetConfigPropertyDelegate(
val defaultValue: T
) : ReadOnlyProperty> {
@Volatile private var _value: RuleSetConfigProperty? = null
override fun getValue(thisRef: Any?, property: KProperty<*>): RuleSetConfigProperty =
_value ?: RuleSetConfigProperty(property.name, defaultValue).also { _value = it }
}
class RuleSetConfigProperty(val key: String, val defaultValue: T) {
fun value(config: Config): T =
config.valueOrDefault(key, defaultValue)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy