android-beans / rocks.frieler.android.beans / BeanRegistry / lookUpOptionalBean

lookUpOptionalBean

fun <T : Any> lookUpOptionalBean(name: String, type: KClass<T>): T?

Overrides BeansProvider.lookUpOptionalBean

Looks up the bean with the given name and type.

If no bean with that name is registered or the registered bean is not assignable to the required type, null is returned.

Parameters

name - the name of the desired bean

type - the type of the desired bean

Parameters

Return
the named bean or null

fun <T : Any> lookUpOptionalBean(type: KClass<T>): T?

Overrides BeansProvider.lookUpOptionalBean

Looks up a bean of the given type.

If no bean is assignable to the required type, null is returned. If multiple beans are assignable to the required type, the first match is returned.

Parameters

type - the type of the desired bean

Parameters

Return
a bean of the given type or null