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

ifUnique

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

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

Parameters

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

Exceptions

BeansException - in case of creation errors

Since
5.0

See Also
#getIfAvailable()