-
- All Implemented Interfaces:
public final class DelegatesKt
-
-
Method Summary
Modifier and Type Method Description final static <T extends Any> ConfigDelegate<T>config(ConfigSourceSupplier<T> supplier)Create a ConfigDelegate for a single property (no fallback) from only a key and source and fill in the type automatically, enables doing: val port: Int by config("app.server.port".from(configSource)) Instead of: val port: Int by config("app.server.port".from(configSource). final static <T extends Any> ConfigDelegate<T>config(Function1<SupplierBuilder<T>, Unit> block)Create a ConfigDelegate which will query multiple ConfigValueSuppliers, in order, for a given property. final static <T extends Any> ConfigValueSupplier<T>configSupplier(Function1<SupplierBuilder<T>, Unit> block)Create a ConfigValueSupplier which can be used for a non-member field, e.g. final static <T extends Any> OptionalConfigDelegate<T>optionalconfig(ConfigSourceSupplier<T> supplier)Create an OptionalConfigDelegate for a single property (no fallback) from only a key and source (filling in the type automatically), returns null if the property couldn't be retrieved final static <T extends Any> OptionalConfigDelegate<T>optionalconfig(Function1<SupplierBuilder<T>, Unit> block)Create an OptionalConfigDelegate which queries multiple ConfigValueSuppliers for a property, returning null if the property couldn't be retrieved -
-
Method Detail
-
config
final static <T extends Any> ConfigDelegate<T> config(ConfigSourceSupplier<T> supplier)
Create a ConfigDelegate for a single property (no fallback) from only a key and source and fill in the type automatically, enables doing: val port: Int by config("app.server.port".from(configSource)) Instead of: val port: Int by config("app.server.port".from(configSource).asType<Int>()) Since the inline function can fill in the type on its own.
throws ConfigException.UnableToRetrieve if the property couldn't be retrieved
-
config
final static <T extends Any> ConfigDelegate<T> config(Function1<SupplierBuilder<T>, Unit> block)
Create a ConfigDelegate which will query multiple ConfigValueSuppliers, in order, for a given property.
throws ConfigException.UnableToRetrieve if the property couldn't be retrieved
-
configSupplier
final static <T extends Any> ConfigValueSupplier<T> configSupplier(Function1<SupplierBuilder<T>, Unit> block)
Create a ConfigValueSupplier which can be used for a non-member field, e.g.:
fun main(args: Array<String>) { val port: ConfigValueSupplier<Int> = configSupplier { retrieve("app.port".from(configSource)) } }
-
optionalconfig
final static <T extends Any> OptionalConfigDelegate<T> optionalconfig(ConfigSourceSupplier<T> supplier)
Create an OptionalConfigDelegate for a single property (no fallback) from only a key and source (filling in the type automatically), returns null if the property couldn't be retrieved
-
optionalconfig
final static <T extends Any> OptionalConfigDelegate<T> optionalconfig(Function1<SupplierBuilder<T>, Unit> block)
Create an OptionalConfigDelegate which queries multiple ConfigValueSuppliers for a property, returning null if the property couldn't be retrieved
-
-
-
-