final class OptionalBinder.RealOptionalBinder.RealOptionalKeyProvider extends OptionalBinder.RealOptionalBinder.RealOptionalBinderProviderWithDependencies<com.google.common.base.Optional<T>> implements ProviderWithExtensionVisitor<com.google.common.base.Optional<T>>, OptionalBinderBinding<com.google.common.base.Optional<T>>, Provider<com.google.common.base.Optional<T>>
| Modifier | Constructor and Description |
|---|---|
private |
RealOptionalKeyProvider() |
| Modifier and Type | Method and Description |
|---|---|
<B,R> R |
acceptExtensionVisitor(BindingTargetVisitor<B,R> visitor,
ProviderInstanceBinding<? extends B> 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.
|
com.google.common.base.Optional<T> |
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<com.google.common.base.Optional<T>> |
getKey()
Returns the
Key for this binding. |
equals, hashCodepublic com.google.common.base.Optional<T> get()
ProviderT. Must never return null.get in interface javax.inject.Provider<com.google.common.base.Optional<T>>public java.util.Set<Dependency<?>> getDependencies()
HasDependenciesInjector will be
included in the returned set.getDependencies in interface HasDependenciespublic <B,R> R acceptExtensionVisitor(BindingTargetVisitor<B,R> visitor, ProviderInstanceBinding<? extends B> 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 ProviderWithExtensionVisitor<com.google.common.base.Optional<T>>public Key<com.google.common.base.Optional<T>> getKey()
OptionalBinderBindingKey for this binding.getKey in interface OptionalBinderBinding<com.google.common.base.Optional<T>>public 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 OptionalBinderBinding<com.google.common.base.Optional<T>>public 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 OptionalBinderBinding<com.google.common.base.Optional<T>>public 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 OptionalBinderBinding<com.google.common.base.Optional<T>>