instanceOrNull

inline fun <T : Any> DIAware.instanceOrNull(tag: Any? = null): LazyDelegate<T?>

Gets an instance of T for the given type and tag, or null if none is found.

T generics will be erased!

Return

An instance, or null if no provider was found.

Parameters

T

The type of object to retrieve.

tag

The bound tag, if any.

Throws

If the instance construction triggered a dependency loop.


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

Gets an instance of T for the given type and tag, curried from a factory that takes an argument A, or null if none is found.

A & T generics will be erased!

Return

An instance of T, or null if no factory was found.

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 the value construction triggered a dependency loop.


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

Gets an instance of T for the given type and tag, curried from a factory that takes an argument A, or null if none is found.

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

A & T generics will be erased!

Return

An instance of T, or null if no factory was found.

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 the value construction triggered a dependency loop.


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

Gets an instance of T for the given type and tag, curried from a factory that takes an argument A, or null if none is found.

A & T generics will be erased!

Return

An instance of T, or null if no factory was found.

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 the value construction triggered a dependency loop.


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

Gets an instance of T for the given type and tag, or null if none is found.

T generics will be erased.

Return

An instance, or null if no provider was found.

Parameters

T

The type of object to retrieve.

tag

The bound tag, if any.

Throws

If the instance construction triggered a dependency loop.


inline fun <A : Any, T : Any> DirectDIAware.instanceOrNull(tag: Any? = null, arg: A): T?
inline fun <A, T : Any> DirectDIAware.instanceOrNull(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, or null if none is found.

A & T generics will be erased.

Return

A instance of T, or null if no provider was found.

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

A function that returns 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.instanceOrNull(): LazyDelegate<T?>

Gets an instance of T for the given type, or null if none is found. The name of the receiving property is used as tag.

T generics will be erased!

Return

An instance, or null if no provider was found.

Parameters

T

The type of object to retrieve.

Throws

If the instance construction triggered a dependency loop.


inline fun <A : Any, T : Any> Named.instanceOrNull(arg: A): LazyDelegate<T?>

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

A & T generics will be erased!

Return

An instance of T, or null if no factory was found.

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 the value construction triggered a dependency loop.


inline fun <A, T : Any> Named.instanceOrNull(arg: Typed<A>): LazyDelegate<T?>

Gets an instance of T for the given type, curried from a factory that takes an argument A, or null if none is found. 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, or null if no factory was found.

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 the value construction triggered a dependency loop.


inline fun <A : Any, T : Any> Named.instanceOrNull(noinline fArg: () -> A): LazyDelegate<T?>

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

A & T generics will be erased!

Return

An instance of T, or null if no factory was found.

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 the value construction triggered a dependency loop.