winter / io.jentz.winter / Graph

Graph

class Graph

The object graph class that retrieves and instantiates dependencies registered in its component.

An instance is created by calling Component.createGraph, Graph.createSubgraph or Graph.openSubgraph.

Properties

application

val application: WinterApplication

The WinterApplication of this graph.

component

val component: Component

The Component instance.

isDisposed

val isDisposed: Boolean

Indicates if the graph is disposed.

parent

val parent: Graph?

The parent Graph instance or null if no parent exists.

Functions

closeSubgraph

fun closeSubgraph(identifier: Any): Unit

Close a subgraph by disposing it and removing it from the registry.

createSubgraph

fun createSubgraph(subcomponentQualifier: Any, block: ComponentBuilderBlock? = null): Graph

Initialize and return a subgraph by using the subcomponent with subcomponentQualifier and this graph as parent.

dispose

fun dispose(): Unit

Runs graph dispose plugins and marks this graph as disposed. All resources get released and every retrieval method will throw an exception if called after disposing.

evaluate

fun <A, R : Any> evaluate(service: BoundService<A, R>, argument: A): R

This is called from BoundService.instance when a new instance is created. Don't use this method except in custom BoundService implementations.

factory

fun <A : Any, R : Any> factory(qualifier: Any? = null, generics: Boolean = false): Factory<A, R>

Retrieve a non-optional factory function that takes an argument of type A and returns R.

factoryByKey

fun <A : Any, R : Any> factoryByKey(key: TypeKey): Factory<A, R>

Retrieve a non-optional factory function by key that takes an argument of type A and returns R.

factoryOrNull

fun <A : Any, R : Any> factoryOrNull(qualifier: Any? = null, generics: Boolean = false): Factory<A, R>?

Retrieve an optional factory function that takes an argument of type A and returns R.

factoryOrNullByKey

fun <A : Any, R : Any> factoryOrNullByKey(key: TypeKey): Factory<A, R>?

Retrieve an optional factory function by key that takes an argument of type A and returns R.

inject

fun <T : Any> inject(instance: T, injectSuperClasses: Boolean = false): T

Inject members of class T.

instance

fun <R : Any> instance(qualifier: Any? = null, generics: Boolean = false): R

Retrieve a non-optional instance of R.

fun <A, R : Any> instance(argument: A, qualifier: Any? = null, generics: Boolean = false): R

Retrieve a factory of type (A) -> R and apply argument to it.

instanceByKey

fun <A, R : Any> instanceByKey(key: TypeKey, argument: A): R

Retrieve a factory of type (A) -> R by key and apply argument to it.

instanceOrNull

fun <R : Any> instanceOrNull(qualifier: Any? = null, generics: Boolean = false): R?

Retrieve an optional instance of R.

fun <A, R : Any> instanceOrNull(argument: A, qualifier: Any? = null, generics: Boolean = false): R?

Retrieve an optional factory of type (A) -> R and apply argument to it.

instanceOrNullByKey

fun <A, R : Any> instanceOrNullByKey(key: TypeKey, argument: A): R?

Retrieve an optional factory of type (A) -> R by key and apply argument to it.

instancesOfType

fun <T : Any> instancesOfType(generics: Boolean = false): Set<T>

Retrieve all instances of type T.

openSubgraph

fun openSubgraph(subcomponentQualifier: Any, identifier: Any? = null, block: ComponentBuilderBlock? = null): Graph

Initialize and return a subgraph by using the subcomponent with subcomponentQualifier and this graph as parent and register it under the subcomponentQualifier or when given under identifier.

provider

fun <R : Any> provider(qualifier: Any? = null, generics: Boolean = false): Provider<R>

Retrieves a non-optional provider function that returns R.

fun <A, R : Any> provider(argument: A, qualifier: Any? = null, generics: Boolean = false): Provider<R>

Retrieves a factory of type (A) -> R and creates and returns a provider that applies the given argument to the factory when called.

providerByKey

fun <A, R : Any> providerByKey(key: TypeKey, argument: A): Provider<R>

Retrieves a factory of type (A) -> R by key and creates and returns a provider that applies the given argument to the factory when called.

providerOrNull

fun <R : Any> providerOrNull(qualifier: Any? = null, generics: Boolean = false): Provider<R>?

Retrieve an optional provider function that returns R.

fun <A, R : Any> providerOrNull(argument: A, qualifier: Any? = null, generics: Boolean = false): Provider<R>?

Retrieves an optional factory of type (A) -> R and creates and returns a provider that applies the given argument to the factory when called.

providerOrNullByKey

fun <A, R : Any> providerOrNullByKey(key: TypeKey, argument: A): Provider<R>?

Retrieves an optional factory of type (A) -> R by key and creates and returns a provider that applies the given argument to the factory when called.

providersOfType

fun <T : Any> providersOfType(generics: Boolean = false): Set<Provider<T>>

Retrieve all providers of type T.