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.

isClosed

val isClosed: Boolean

Indicates if the graph is closed.

parent

val parent: Graph?

The parent Graph instance or null if no parent exists.

Functions

close

fun close(): Unit

Runs graph close plugins and marks this graph as closed. All resources get released and every retrieval method will throw an exception if called after closing.

closeSubgraph

fun closeSubgraph(identifier: Any): Unit

Close a subgraph and remove it from the registry.

closeSubgraphIfOpen

fun closeSubgraphIfOpen(identifier: Any): Unit

Close a subgraph and remove it from the registry if it is open.

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.

evaluate

fun <R : Any> evaluate(service: BoundService<R>): R

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

getOrOpenSubgraph

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

Get a subgraph by identifier if present or open and return it.

getSubgraph

fun getSubgraph(identifier: Any): Graph

Get a subgraph by identifier.

getSubgraphOrNull

fun getSubgraphOrNull(identifier: Any): Graph?

Get an optional subgraph by identifier.

inject

fun <T : Any> inject(instance: T): 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.

instanceByKey

fun <R : Any> instanceByKey(key: TypeKey<R>): R

Retrieve a non-optional instance of R by key.

instanceOrNull

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

Retrieve an optional instance of R.

instanceOrNullByKey

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

Retrieve an optional instance of R by key.

keys

fun keys(): Set<TypeKey<*>>

Returns a set of all keys registered on the backing Component and all the ancestor components.

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.

providerByKey

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

Retrieves a non-optional provider function by key that returns R.

providerOrNull

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

Retrieve an optional provider function that returns R.

providerOrNullByKey

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

Retrieve an optional provider function by key that returns R.