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, hashCode
public java.lang.Object get()
Provider
T
. Must never return null
.get
in interface javax.inject.Provider
public java.util.Set<Dependency<?>> getDependencies()
HasDependencies
Injector
will be
included in the returned set.getDependencies
in interface HasDependencies
public java.lang.Object acceptExtensionVisitor(BindingTargetVisitor visitor, ProviderInstanceBinding binding)
ProviderWithExtensionVisitor
Due 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
public boolean containsElement(Element element)
OptionalBinderBinding
Elements.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
public Binding getActualBinding()
OptionalBinderBinding
OptionalBinder.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
public Binding getDefaultBinding()
OptionalBinderBinding
OptionalBinder.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
public Key getKey()
OptionalBinderBinding
Key
for this binding.getKey
in interface OptionalBinderBinding