public interface ObjectProvider<T> extends ObjectFactory<T>
ObjectFactory designed specifically for injection points,
allowing for programmatic optionality and lenient not-unique handling.| Modifier and Type | Method and Description |
|---|---|
T |
getIfAvailable()
Return an instance (possibly shared or independent) of the object
managed by this factory.
|
default T |
getIfAvailable(java.util.function.Supplier<T> defaultSupplier)
Return an instance (possibly shared or independent) of the object
managed by this factory.
|
T |
getIfUnique()
Return an instance (possibly shared or independent) of the object
managed by this factory.
|
default T |
getIfUnique(java.util.function.Supplier<T> defaultSupplier)
Return an instance (possibly shared or independent) of the object
managed by this factory.
|
T |
getObject(java.lang.Object... args)
Return an instance (possibly shared or independent) of the object
managed by this factory.
|
getObjectT getObject(java.lang.Object... args) throws BeansException
Allows for specifying explicit construction arguments, along the
lines of BeanFactory.getBean(String, Object...).
args - arguments to use when creating a corresponding instanceBeansException - in case of creation errorsObjectFactory.getObject()T getIfAvailable() throws BeansException
null if not availableBeansException - in case of creation errorsObjectFactory.getObject()default T getIfAvailable(java.util.function.Supplier<T> defaultSupplier) throws BeansException
defaultSupplier - a callback for supplying a default object
if none is present in the factoryBeansException - in case of creation errorsgetIfAvailable()T getIfUnique() throws BeansException
null if not available or
not unique (i.e. multiple candidates found with none marked as primary)BeansException - in case of creation errorsObjectFactory.getObject()default T getIfUnique(java.util.function.Supplier<T> defaultSupplier) throws BeansException
defaultSupplier - a callback for supplying a default object
if no unique candidate is present in the factoryBeansException - in case of creation errorsgetIfUnique()