doc / ch.tutteli.atrium.creating / ComponentFactoryContainer

ComponentFactoryContainer

interface ComponentFactoryContainer (source)

Manages the factories to create the different components of Atrium. It takes basically the responsibility of a dependency injection facility, tailored for Atrium.

Functions

buildChainedOrNull

abstract fun <I : Any> buildChainedOrNull(kClass: KClass<I>): Sequence<I>?

Returns a chain of components of type I using a corresponding chain of factories or null in case no chain was found which is able to build a chain of components of the given type.

buildOrNull

abstract fun <I : Any> buildOrNull(kClass: KClass<I>): I?

Returns the component of type I using a corresponding factory or null in case no factory was found which is able to build a component of the given type.

getFactoryForChainedOrNull

abstract fun getFactoryForChainedOrNull(kClass: KClass<*>): Sequence<ComponentFactory>?

Returns a chain of factories which shall build a chain of components of the specified kClass or null in case no chain was found which is able to build a chain of components of the given type.

getFactoryOrNull

abstract fun getFactoryOrNull(kClass: KClass<*>): ComponentFactory?

Returns a factory which is able to build a component for the given kClass or null in case no factory was found which is able to build a component of the given type.

merge

abstract fun merge(componentFactoryContainer: ComponentFactoryContainer?): ComponentFactoryContainer

Merges the given componentFactoryContainer (if not null) with this ComponentFactoryContainer creating a new ComponentFactoryContainer where defined dependencies in componentFactoryContainer will have precedence over dependencies defined in this instance.

Companion Object Functions

createIfNotEmpty

fun createIfNotEmpty(components: Map<KClass<*>, ComponentFactory>, chainedComponents: Map<KClass<*>, Sequence<ComponentFactory>>): ComponentFactoryContainer?

Extension Functions

build

fun <I : Any> ComponentFactoryContainer.build(): I

Returns the component of type I using a corresponding factory or throws an IllegalStateException in case no factory was found which is able to build a component of the given type.

buildChained

fun <I : Any> ComponentFactoryContainer.buildChained(): Sequence<I>

Returns a chain of components of type I using a corresponding factory or throws an IllegalStateException in case no factory was found which is able to build a chain of components of the given type.