spring-framework / org.springframework.beans.factory / ObjectProvider / ifAvailable

ifAvailable

open fun ifAvailable(dependencyConsumer: Consumer<T>): Unit

Consume an instance (possibly shared or independent) of the object managed by this factory, if available.

Parameters

dependencyConsumer - a callback for processing the target object if available (not called otherwise)

Exceptions

BeansException - in case of creation errors

Since
5.0

See Also
#getIfAvailable()