T - the bean-typepublic class OptionalSingleBeanDependency<T> extends java.lang.Object implements BeanDependency<java8.util.Optional<T>>
BeanDependency to express an optional dependency on a single bean.
This kind of dependency always indicates to be fulfilled and will try to provide the
wanted by obtaining it from the BeansProvider as late as possible.
BeanDependency.Fulfillment| Constructor and Description |
|---|
OptionalSingleBeanDependency(java.lang.Class<? extends T> type)
Creates a new optional
BeanDependency to a bean of the given type. |
OptionalSingleBeanDependency(java.lang.String name,
java.lang.Class<? extends T> type)
Creates a new optional
BeanDependency to a bean with the given name and of the given type. |
| Modifier and Type | Method and Description |
|---|---|
BeanDependency.Fulfillment |
fulfill(BeansProvider beansProvider)
Tries to fulfill this
BeanDependency with beans from the given BeansProvider and returns
the state of fulfillment. |
java8.util.Optional<T> |
get()
Returns the target of this
BeanDependency after it was fulfilled. |
public OptionalSingleBeanDependency(java.lang.Class<? extends T> type)
BeanDependency to a bean of the given type.type - the type of the beanpublic OptionalSingleBeanDependency(java.lang.String name,
java.lang.Class<? extends T> type)
BeanDependency to a bean with the given name and of the given type.name - the name of the beantype - the type of the beanpublic BeanDependency.Fulfillment fulfill(BeansProvider beansProvider)
BeanDependency with beans from the given BeansProvider and returns
the state of fulfillment.
As long as there is no suitable bean for this dependency is available, this dependency is
Fulfillment#UNFULFILLED_OPTIONAL. After a suitable bean could be obtained, this dependency is
Fulfillment#FULFILLED and the BeansProvider will no linger be queried.
fulfill in interface BeanDependency<java8.util.Optional<T>>beansProvider - the BeansProvider to obtain beans fromBeanDependency.Fulfillmentpublic java8.util.Optional<T> get()
BeanDependencyBeanDependency after it was fulfilled.get in interface BeanDependency<java8.util.Optional<T>>BeanDependency