Package guru.zoroark.tegral.di.dsl

Tegral DI's DSL utilities. Provides a simple way of creating injection environments and injectable modules.

Types

Link copied to clipboard
interface ContextBuilderDsl

Context for Tegral DI builders, such as module builders (tegralDiModule) or environment builders (tegralDi).

Link copied to clipboard

Builder DSL for creating an environment.This part of the DSL is specifically responsible for creating an EnvironmentContext.

Link copied to clipboard
class ModuleBuilderDsl(name: String) : ContextBuilderDsl, Buildable<InjectableModule>

DSL builder class for InjectableModules. It does not add functionality other than the building logic. All DSL functionalities are provided as extension functions of ContextBuilderDsl.

Functions

Link copied to clipboard
fun ContextBuilderDsl.put(module: InjectableModule)

Add a module to the current definition. This adds all the declarations within the module to this context.

inline fun <T : Any> ContextBuilderDsl.put(noinline supplier: ScopedSupplier<T>): ScopedSupplierDeclaration<T>

Add a definition of type T with the given supplier.

inline fun <T : Any> ContextBuilderDsl.put(supplier: KFunction<T>): ScopedSupplierDeclaration<T>

Add a definition of type T with the given constructor.

inline fun <T : Any> ContextBuilderDsl.put(qualifier: Qualifier, noinline supplier: ScopedSupplier<T>): ScopedSupplierDeclaration<T>
fun <T : Any> ContextBuilderDsl.put(    kclass: KClass<T>,     qualifier: Qualifier = EmptyQualifier,     supplier: ScopedSupplier<T>): ScopedSupplierDeclaration<T>

Add a definition of type T with the given qualifier and supplier.

inline fun <T : Any> ContextBuilderDsl.put(qualifier: Qualifier, supplier: KFunction<T>): ScopedSupplierDeclaration<T>

Add a definition of type T with the given qualifier and constructor.

fun <T : Any> ContextBuilderDsl.put(kclass: KClass<T>, supplier: KFunction<T>): ScopedSupplierDeclaration<T>

Add a definition of type T with the given class and constructor.

fun <T : Any> ContextBuilderDsl.put(    kclass: KClass<T>,     qualifier: Qualifier,     supplier: KFunction<T>): ScopedSupplierDeclaration<T>

Add a definition of type T with the given class, qualifier and constructor.

Link copied to clipboard
fun tegralDi(builder: ExtensibleContextBuilderDsl.() -> Unit): MixedImmutableEnvironment
fun <E : InjectionEnvironment> tegralDi(environmentKind: InjectionEnvironmentKind<E>, builder: ContextBuilderDsl.() -> Unit): E
fun <E : ExtensibleInjectionEnvironment> tegralDi(    environmentKind: ExtensibleInjectionEnvironmentKind<E>,     metaEnvironmentKind: InjectionEnvironmentKind<*> = EagerImmutableMetaEnvironment,     builder: ExtensibleContextBuilderDsl.() -> Unit): E

Entry point for the Tegral DI DSL, used to build an injection environment.

Link copied to clipboard
fun tegralDiModule(name: String = "<unnamed module>", builder: ContextBuilderDsl.() -> Unit): InjectableModule

Creates a module using the Tegral DI DSL with an optional name. You can then use the put function to add this module to environment builders like the block in tegralDi.