-
- All Implemented Interfaces:
public final class SupplierBuilder<T extends Object>This class enables us to implicitly inject the type when a caller is building a property, for example: val bool: Boolean by config { "some.path".from(configSource) // no need to explicitly set the type "some.other.path".from(configSource).transformedBy { !it } // again, don't need to set the type // can override the inferred type when you want to convert "some.third.path".from(configSource).convertFrom<Long> { it 0 } }
-
-
Constructor Summary
Constructors Constructor Description SupplierBuilder(KType finalType)
-
Method Summary
Modifier and Type Method Description final List<ConfigValueSupplier<T>>getSuppliers()final KTypegetFinalType()final ConfigSourceSupplier<T>from(String $self, ConfigSource configSource)Given a key and a source, create a ConfigSourceSupplier with an inferred type. final ConfigValueSupplier<T>softDeprecated(ConfigValueSupplier<T> $self, String msg)Mark the source key of the value from this supplier as soft deprecated final ConfigValueSupplier<T>hardDeprecated(ConfigValueSupplier<T> $self, String msg)Mark the source key of the value from this supplier as hard deprecated final ConfigValueSupplier<T>transformedBy(ConfigValueSupplier<T> $self, Function1<T, T> transformer)Add a value transformation operation final <RetrieveType extends Any> TypeConvertingSupplier<RetrieveType, T>convertFrom(ConfigSourceSupplier<T> $self, Function1<RetrieveType, T> converter)Add a type conversion operation. final Unitinvoke(String $self, Function0<T> lambda)Create a LambdaSupplier with a String context, a la: ...by config { ... final UnitonlyIf(String context, Function0<Boolean> predicate, Function1<SupplierBuilder<T>, Unit> block)Wrap a set of inner suppliers in a condition guard -
-
Constructor Detail
-
SupplierBuilder
SupplierBuilder(KType finalType)
-
-
Method Detail
-
getSuppliers
final List<ConfigValueSupplier<T>> getSuppliers()
-
getFinalType
final KType getFinalType()
-
from
final ConfigSourceSupplier<T> from(String $self, ConfigSource configSource)
Given a key and a source, create a ConfigSourceSupplier with an inferred type.
-
softDeprecated
final ConfigValueSupplier<T> softDeprecated(ConfigValueSupplier<T> $self, String msg)
Mark the source key of the value from this supplier as soft deprecated
-
hardDeprecated
final ConfigValueSupplier<T> hardDeprecated(ConfigValueSupplier<T> $self, String msg)
Mark the source key of the value from this supplier as hard deprecated
-
transformedBy
final ConfigValueSupplier<T> transformedBy(ConfigValueSupplier<T> $self, Function1<T, T> transformer)
Add a value transformation operation
-
convertFrom
final <RetrieveType extends Any> TypeConvertingSupplier<RetrieveType, T> convertFrom(ConfigSourceSupplier<T> $self, Function1<RetrieveType, T> converter)
Add a type conversion operation. This is only able to be applied on top of a ConfigSourceSupplier, because we need to recreate the underlying supplier to retrieve a different type than was originally inferred (we can add support for other suppliers where this makes sense as the need arises).
-
invoke
final Unit invoke(String $self, Function0<T> lambda)
Create a LambdaSupplier with a String context, a la: ...by config { ... "From an object" { MyFoo.port } ... } LambdaSuppliers don't require construction as they are entirely responsible for producing the value, so they have their own method
-
-
-
-