final class OptionalBinder.RealOptionalBinder.JavaOptionalProvider extends OptionalBinder.RealOptionalBinder.RealOptionalBinderProviderWithDependencies implements ProviderWithExtensionVisitor, OptionalBinderBinding
| Modifier | Constructor and Description |
|---|---|
private |
JavaOptionalProvider() |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
acceptExtensionVisitor(BindingTargetVisitor visitor,
ProviderInstanceBinding binding)
Instructs the extension determine if the visitor is an instance of a custom
extension visitor, and if so, visit it using that method.
|
boolean |
containsElement(Element element)
Returns true if this OptionalBinder contains the given Element in order to build the optional
binding or uses the given Element in order to support building and injecting its data.
|
java.lang.Object |
get()
Provides an instance of
T. |
Binding |
getActualBinding()
Returns the actual binding (set by
OptionalBinder.setBinding()) or null if not set. |
Binding |
getDefaultBinding()
Returns the default binding (set by
OptionalBinder.setDefault()) if one exists or null
if no default binding is set. |
java.util.Set<Dependency<?>> |
getDependencies()
Returns the known dependencies for this type.
|
Key |
getKey()
Returns the
Key for this binding. |
equals, hashCodepublic java.lang.Object get()
ProviderT. Must never return null.get in interface javax.inject.Providerpublic java.util.Set<Dependency<?>> getDependencies()
HasDependenciesInjector will be
included in the returned set.getDependencies in interface HasDependenciespublic java.lang.Object acceptExtensionVisitor(BindingTargetVisitor visitor, ProviderInstanceBinding binding)
ProviderWithExtensionVisitorDue to issues with generics, the type parameters of this method do not relate to the type of the provider. In practice, the 'B' type will always be a supertype of 'T'.
acceptExtensionVisitor in interface ProviderWithExtensionVisitorpublic boolean containsElement(Element element)
OptionalBinderBindingElements.getElements(com.google.inject.Module...). Usually this is only necessary if you are working with elements
retrieved from modules (without an Injector), otherwise OptionalBinderBinding.getDefaultBinding() and
OptionalBinderBinding.getActualBinding() are better options.containsElement in interface OptionalBinderBindingpublic Binding getActualBinding()
OptionalBinderBindingOptionalBinder.setBinding()) or null if not set.
This will throw UnsupportedOperationException if it is called on an element retrieved
from Elements.getElements(com.google.inject.Module...).
The Binding's type will always match the type Optional's generic type. For example, if getKey
returns a key of Optional<String>, then this will always return a
Binding<String>.
getActualBinding in interface OptionalBinderBindingpublic Binding getDefaultBinding()
OptionalBinderBindingOptionalBinder.setDefault()) if one exists or null
if no default binding is set. This will throw UnsupportedOperationException if it is
called on an element retrieved from Elements.getElements(com.google.inject.Module...).
The Binding's type will always match the type Optional's generic type. For example, if getKey
returns a key of Optional<String>, then this will always return a
Binding<String>.
getDefaultBinding in interface OptionalBinderBindingpublic Key getKey()
OptionalBinderBindingKey for this binding.getKey in interface OptionalBinderBinding