instance

inline fun <T : Any> DI.Builder.instance(instance: T): InstanceBinding<T>

Creates an instance provider: will always return the given instance.

T generics will be erased!

Return

An instance provider ready to be bound.

Parameters

T

The type of the instance.

instance

The object that will always be returned.

inline fun <T : Any> DIAware.instance(tag: Any? = null): DIProperty<T>

Gets an instance of T for the given type and tag.

T generics will be preserved!

Return

An instance.

Parameters

T

The type of object to retrieve.

tag

The bound tag, if any.

Throws

if no provider was found.

If the instance construction triggered a dependency loop.

inline fun <A : Any, T : Any> DIAware.instance(tag: Any? = null, arg: A): DIProperty<T>

Gets an instance of T for the given type and tag, curried from a factory that takes an argument A.

A & T generics will be preserved!

Return

An instance of T.

Parameters

A

The type of argument the curried factory takes.

T

The type of object to retrieve.

tag

The bound tag, if any.

arg

The argument that will be given to the factory when curried.

Throws

If no provider was found.

If the value construction triggered a dependency loop.

inline fun <A, T : Any> DIAware.instance(tag: Any? = null, arg: Typed<A>): DIProperty<T>

Gets an instance of T for the given type and tag, curried from a factory that takes an argument A.

The argument type is extracted from the Typed.type of the argument.

A & T generics will be erased!

Return

An instance of T.

Parameters

A

The type of argument the curried factory takes.

T

The type of object to retrieve.

tag

The bound tag, if any.

arg

The argument that will be given to the factory when curried.

Throws

If no provider was found.

If the value construction triggered a dependency loop.

inline fun <A : Any, T : Any> DIAware.instance(tag: Any? = null, noinline fArg: () -> A): DIProperty<T>

Gets an instance of T for the given type and tag, curried from a factory that takes an argument A.

A & T generics will be erased!

Return

An instance of T.

Parameters

A

The type of argument the curried factory takes.

T

The type of object to retrieve.

tag

The bound tag, if any.

fArg

A function that returns the argument that will be given to the factory when curried.

Throws

If no provider was found.

If the value construction triggered a dependency loop.

inline fun <T : Any> DirectDIAware.instance(tag: Any? = null): T

Gets an instance of T for the given type and tag.

T generics will be erased.

Return

An instance.

Parameters

T

The type of object to retrieve.

tag

The bound tag, if any.

Throws

if no provider was found.

If the instance construction triggered a dependency loop.

inline fun <A : Any, T : Any> DirectDIAware.instance(tag: Any? = null, arg: A): T

Gets an instance of T for the given type and tag, curried from a factory for the given argument.

A & T generics will be erased.

Return

An instance of T.

Parameters

A

The type of argument the curried factory takes.

T

The type of object to retrieve with the returned provider.

tag

The bound tag, if any.

arg

The argument that will be given to the factory when curried.

Throws

If no provider was found.

When calling the provider, if the value construction triggered a dependency loop.

inline fun <A, T : Any> DirectDIAware.instance(tag: Any? = null, arg: Typed<A>): T

Gets an instance of T for the given type and tag, curried from a factory for the given argument.

The argument type is extracted from the Typed.type of the argument.

A & T generics will be erased.

Return

An instance of T.

Parameters

A

The type of argument the curried factory takes.

T

The type of object to retrieve with the returned provider.

tag

The bound tag, if any.

arg

The argument that will be given to the factory when curried.

Throws

If no provider was found.

When calling the provider, if the value construction triggered a dependency loop.

inline fun <T : Any> Named.instance(): DIProperty<T>

Gets an instance of T for the given type. The name of the receiving property is used as tag.

T generics will be erased!

Return

An instance.

Parameters

T

The type of object to retrieve.

Throws

if no provider was found.

If the instance construction triggered a dependency loop.

inline fun <A : Any, T : Any> Named.instance(arg: A): DIProperty<T>

Gets an instance of T for the given type, curried from a factory that takes an argument A. The name of the receiving property is used as tag.

A & T generics will be erased!

Return

An instance of T.

Parameters

A

The type of argument the curried factory takes.

T

The type of object to retrieve.

arg

The argument that will be given to the factory when curried.

Throws

If no provider was found.

If the value construction triggered a dependency loop.

inline fun <A, T : Any> Named.instance(arg: Typed<A>): DIProperty<T>

Gets an instance of T for the given type, curried from a factory that takes an argument A. The name of the receiving property is used as tag.

The argument type is extracted from the Typed.type of the argument.

A & T generics will be erased!

Return

An instance of T.

Parameters

A

The type of argument the curried factory takes.

T

The type of object to retrieve.

arg

The argument that will be given to the factory when curried.

Throws

If no provider was found.

If the value construction triggered a dependency loop.

inline fun <A : Any, T : Any> Named.instance(noinline fArg: () -> A): DIProperty<T>

Gets an instance of T for the given type, curried from a factory that takes an argument A. The name of the receiving property is used as tag.

A & T generics will be erased!

Return

An instance of T.

Parameters

A

The type of argument the curried factory takes.

T

The type of object to retrieve.

fArg

A function that returns the argument that will be given to the factory when curried.

Throws

If no provider was found.

If the value construction triggered a dependency loop.