configWithFallback

fun <T : Any> configWithFallback(fallbackProperty: KProperty0<T>, defaultValue: T): ReadOnlyProperty<Rule, T>

Creates a delegated read-only property that can be used in ConfigAware objects. The name of the property is the key that is used during configuration lookup. If there is no such property, the value of the supplied fallbackProperty is also considered before using the defaultValue. The value of the property is evaluated only once.

This method is only intended to be used in migration scenarios where there is no way to update all configuration files immediately.

Parameters

fallbackProperty

The reference to the configuration key to fall back to. This property must be defined as a configuration delegate.

defaultValue

the value that the property evaluates to when there is no key with the name of the property in the config. Although T is defined as Any, only String, Int, Boolean and List are supported.


fun <T : Any, U : Any> configWithFallback(fallbackProperty: KProperty0<U>, defaultValue: T, transformer: (T) -> U): ReadOnlyProperty<Rule, U>

Creates a delegated read-only property that can be used in ConfigAware objects. The name of the property is the key that is used during configuration lookup. If there is no such property, the value of the supplied fallbackProperty is also considered before using the defaultValue. The value of the property is evaluated and transformed only once.

This method is only intended to be used in migration scenarios where there is no way to update all configuration files immediately.

Parameters

fallbackProperty

The reference to the configuration key to fall back to. This property must be defined as a configuration delegate.

defaultValue

the value that the property evaluates to when there is no key with the name of the property in the config. Although T is defined as Any, only String, Int, Boolean and List are supported.

transformer

a function that transforms the value from the configuration (or the default) into its final value.