Package com.google.inject.internal
Class RealOptionalBinder<T>
- java.lang.Object
-
- com.google.inject.internal.RealOptionalBinder<T>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static interface
RealOptionalBinder.Actual
(package private) static class
RealOptionalBinder.ActualImpl
(package private) static class
RealOptionalBinder.BaseAnnotation
private static class
RealOptionalBinder.BindingSelection<T>
A helper object that implements the core logic for deciding what the implementation of the binding will be.(package private) static interface
RealOptionalBinder.Default
(package private) static class
RealOptionalBinder.DefaultImpl
private static class
RealOptionalBinder.JavaOptionalProvider<T>
Provides the binding for java.util.Optional. private static class
RealOptionalBinder.JavaOptionalProviderProvider<T>
Provides the binding for java.util.Optional>. private static class
RealOptionalBinder.RealDirectTypeProvider<T>
Provides the binding for T, conditionally installed by calling setBinding/setDefault.private static class
RealOptionalBinder.RealOptionalBinderProviderWithDependencies<T,P>
A base class for ProviderWithDependencies that need equality based on a specific object.private static class
RealOptionalBinder.RealOptionalKeyProvider<T>
Provides the binding for Optional. private static class
RealOptionalBinder.RealOptionalProviderProvider<T>
Provides the binding for Optional>. (package private) static class
RealOptionalBinder.Source
-
Field Summary
Fields Modifier and Type Field Description private Binder
binder
private RealOptionalBinder.BindingSelection<T>
bindingSelection
-
Constructor Summary
Constructors Modifier Constructor Description private
RealOptionalBinder(Binder binder, Key<T> typeKey)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addDirectTypeBinding(Binder binder)
Adds a binding for T.void
configure(Binder binder)
Contributes bindings and other configurations for this module tobinder
.boolean
equals(java.lang.Object o)
(package private) Key<T>
getKeyForActualBinding()
Returns the key to use for the actual binding, overrides the default if set.(package private) Key<T>
getKeyForDefaultBinding()
Returns the key to use for the default binding.int
hashCode()
(package private) static <T> TypeLiteral<java.util.Optional<T>>
javaOptionalOf(TypeLiteral<T> type)
(package private) static <T> TypeLiteral<java.util.Optional<javax.inject.Provider<T>>>
javaOptionalOfJavaxProvider(TypeLiteral<T> type)
(package private) static <T> TypeLiteral<java.util.Optional<Provider<T>>>
javaOptionalOfProvider(TypeLiteral<T> type)
static <T> RealOptionalBinder<T>
newRealOptionalBinder(Binder binder, Key<T> type)
(package private) static <T> TypeLiteral<com.google.common.base.Optional<T>>
optionalOf(TypeLiteral<T> type)
(package private) static <T> TypeLiteral<com.google.common.base.Optional<javax.inject.Provider<T>>>
optionalOfJavaxProvider(TypeLiteral<T> type)
(package private) static <T> TypeLiteral<com.google.common.base.Optional<Provider<T>>>
optionalOfProvider(TypeLiteral<T> type)
(package private) static <T> Key<Provider<T>>
providerOf(Key<T> key)
LinkedBindingBuilder<T>
setBinding()
LinkedBindingBuilder<T>
setDefault()
-
-
-
Field Detail
-
bindingSelection
private final RealOptionalBinder.BindingSelection<T> bindingSelection
-
binder
private final Binder binder
-
-
Method Detail
-
newRealOptionalBinder
public static <T> RealOptionalBinder<T> newRealOptionalBinder(Binder binder, Key<T> type)
-
optionalOf
static <T> TypeLiteral<com.google.common.base.Optional<T>> optionalOf(TypeLiteral<T> type)
-
javaOptionalOf
static <T> TypeLiteral<java.util.Optional<T>> javaOptionalOf(TypeLiteral<T> type)
-
optionalOfJavaxProvider
static <T> TypeLiteral<com.google.common.base.Optional<javax.inject.Provider<T>>> optionalOfJavaxProvider(TypeLiteral<T> type)
-
javaOptionalOfJavaxProvider
static <T> TypeLiteral<java.util.Optional<javax.inject.Provider<T>>> javaOptionalOfJavaxProvider(TypeLiteral<T> type)
-
optionalOfProvider
static <T> TypeLiteral<com.google.common.base.Optional<Provider<T>>> optionalOfProvider(TypeLiteral<T> type)
-
javaOptionalOfProvider
static <T> TypeLiteral<java.util.Optional<Provider<T>>> javaOptionalOfProvider(TypeLiteral<T> type)
-
addDirectTypeBinding
private void addDirectTypeBinding(Binder binder)
Adds a binding for T. Multiple calls to this are safe, and will be collapsed as duplicate bindings.
-
getKeyForDefaultBinding
Key<T> getKeyForDefaultBinding()
Returns the key to use for the default binding.As a side effect this installs support for the 'direct type', so a binding for
T
will be made available.
-
setDefault
public LinkedBindingBuilder<T> setDefault()
-
getKeyForActualBinding
Key<T> getKeyForActualBinding()
Returns the key to use for the actual binding, overrides the default if set.As a side effect this installs support for the 'direct type', so a binding for
T
will be made available.
-
setBinding
public LinkedBindingBuilder<T> setBinding()
-
configure
public void configure(Binder binder)
Description copied from interface:Module
Contributes bindings and other configurations for this module tobinder
.Do not invoke this method directly to install submodules. Instead use
Binder.install(Module)
, which ensures thatprovider methods
are discovered.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-