Class RealMapBinder.BindingSelection<K,V>
- java.lang.Object
-
- com.google.inject.internal.RealMapBinder.BindingSelection<K,V>
-
- Enclosing class:
- RealMapBinder<K,V>
private static final class RealMapBinder.BindingSelection<K,V> extends java.lang.Object
The BindingSelection contains some of the core state and logic for the MapBinder.It lazily computes the value for keys for various permutations of Maps that are provided by this module. It also builds up maps from
K
toBinding<V>
, which is used by all of the internal factories to actually provide the desired maps.During initialization time there is only one BindingSelection. It is possible that multiple different BindingSelections are constructed. Specifically, in the case of two different modules each adding bindings to the same MapBinder. If that happens, we define the BindingSelection held by the
RealMapBinder.RealMapProvider
to be the authoritative one. The logic for this exists inRealMapBinder.RealMultimapBinderProviderWithDependencies
. This is done to avoid confusion because the BindingSelection contains mutable state.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
RealMapBinder.BindingSelection.InitializationState
-
Field Summary
Fields Modifier and Type Field Description private com.google.common.collect.ImmutableList<java.util.Map.Entry<K,Binding<V>>>
entries
private RealMultibinder<java.util.Map.Entry<K,Provider<V>>>
entrySetBinder
private Key<java.util.Set<java.util.Map.Entry<K,javax.inject.Provider<V>>>>
entrySetJavaxProviderKey
private RealMapBinder.BindingSelection.InitializationState
initializationState
private Key<java.util.Map<K,java.util.Collection<javax.inject.Provider<V>>>>
javaxProviderCollectionMultimapKey
private Key<java.util.Map<K,javax.inject.Provider<V>>>
javaxProviderMapKey
private Key<java.util.Map<K,java.util.Set<javax.inject.Provider<V>>>>
javaxProviderSetMultimapKey
private TypeLiteral<K>
keyType
private com.google.common.collect.ImmutableMap<K,Binding<V>>
mapBindings
These are built during initialization and used by all factories to actually provide the relevant maps.private Key<java.util.Map<K,V>>
mapKey
private com.google.common.collect.ImmutableMap<K,java.util.Set<Binding<V>>>
multimapBindings
private Key<java.util.Map<K,java.util.Set<V>>>
multimapKey
private boolean
permitsDuplicates
Indicates if this Map permits duplicates.private Key<java.util.Map<K,java.util.Collection<Provider<V>>>>
providerCollectionMultimapKey
private Key<java.util.Map<K,Provider<V>>>
providerMapKey
private Key<java.util.Map<K,java.util.Set<Provider<V>>>>
providerSetMultimapKey
private TypeLiteral<V>
valueType
-
Constructor Summary
Constructors Modifier Constructor Description private
BindingSelection(TypeLiteral<K> keyType, TypeLiteral<V> valueType, Key<java.util.Map<K,V>> mapKey, RealMultibinder<java.util.Map.Entry<K,Provider<V>>> entrySetBinder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
containsElement(Element element)
boolean
equals(java.lang.Object o)
private com.google.common.collect.ImmutableList<java.util.Map.Entry<K,Binding<V>>>
getEntries()
private RealMultibinder<java.util.Map.Entry<K,Provider<V>>>
getEntrySetBinder()
private Key<java.util.Set<java.util.Map.Entry<K,javax.inject.Provider<V>>>>
getEntrySetJavaxProviderKey()
private Key<java.util.Map<K,java.util.Collection<javax.inject.Provider<V>>>>
getJavaxProviderCollectionMultimapKey()
private Key<java.util.Map<K,javax.inject.Provider<V>>>
getJavaxProviderMapKey()
private Key<java.util.Map<K,java.util.Set<javax.inject.Provider<V>>>>
getJavaxProviderSetMultimapKey()
private TypeLiteral<K>
getKeyType()
private com.google.common.collect.ImmutableMap<K,Binding<V>>
getMapBindings()
private Key<java.util.Map<K,V>>
getMapKey()
private com.google.common.collect.ImmutableMap<K,java.util.Set<Binding<V>>>
getMultimapBindings()
private Key<java.util.Map<K,java.util.Set<V>>>
getMultimapKey()
private Key<java.util.Map<K,java.util.Collection<Provider<V>>>>
getProviderCollectionMultimapKey()
private Key<java.util.Map<K,Provider<V>>>
getProviderMapKey()
private Key<java.util.Map<K,java.util.Set<Provider<V>>>>
getProviderSetMultimapKey()
private TypeLiteral<V>
getValueType()
int
hashCode()
private boolean
isInitialized()
private boolean
matchesValueKey(Key<?> key)
Returns true if the key indicates this is a value in the map.private boolean
permitsDuplicates()
private static <K,V>
voidreportDuplicateKeysError(com.google.common.collect.Multimap<K,Binding<V>> duplicates, Errors errors)
private boolean
tryInitialize(InjectorImpl injector, Errors errors)
Will initialize internal data structures.
-
-
-
Field Detail
-
keyType
private final TypeLiteral<K> keyType
-
valueType
private final TypeLiteral<V> valueType
-
providerSetMultimapKey
private Key<java.util.Map<K,java.util.Set<Provider<V>>>> providerSetMultimapKey
-
javaxProviderSetMultimapKey
private Key<java.util.Map<K,java.util.Set<javax.inject.Provider<V>>>> javaxProviderSetMultimapKey
-
providerCollectionMultimapKey
private Key<java.util.Map<K,java.util.Collection<Provider<V>>>> providerCollectionMultimapKey
-
javaxProviderCollectionMultimapKey
private Key<java.util.Map<K,java.util.Collection<javax.inject.Provider<V>>>> javaxProviderCollectionMultimapKey
-
entrySetJavaxProviderKey
private Key<java.util.Set<java.util.Map.Entry<K,javax.inject.Provider<V>>>> entrySetJavaxProviderKey
-
entrySetBinder
private final RealMultibinder<java.util.Map.Entry<K,Provider<V>>> entrySetBinder
-
initializationState
private RealMapBinder.BindingSelection.InitializationState initializationState
-
mapBindings
private com.google.common.collect.ImmutableMap<K,Binding<V>> mapBindings
These are built during initialization and used by all factories to actually provide the relevant maps. These contain all of the necessary information about the map binder.
-
multimapBindings
private com.google.common.collect.ImmutableMap<K,java.util.Set<Binding<V>>> multimapBindings
-
permitsDuplicates
private boolean permitsDuplicates
Indicates if this Map permits duplicates. It is initialized during initialization by querying the injector. This is done because multiple different modules can contribute to a MapBinder, and any one could set permitDuplicates.
-
-
Constructor Detail
-
BindingSelection
private BindingSelection(TypeLiteral<K> keyType, TypeLiteral<V> valueType, Key<java.util.Map<K,V>> mapKey, RealMultibinder<java.util.Map.Entry<K,Provider<V>>> entrySetBinder)
-
-
Method Detail
-
tryInitialize
private boolean tryInitialize(InjectorImpl injector, Errors errors)
Will initialize internal data structures.- Returns:
true
if initialization was successful,false
if there were errors
-
reportDuplicateKeysError
private static <K,V> void reportDuplicateKeysError(com.google.common.collect.Multimap<K,Binding<V>> duplicates, Errors errors)
-
containsElement
private boolean containsElement(Element element)
-
matchesValueKey
private boolean matchesValueKey(Key<?> key)
Returns true if the key indicates this is a value in the map.
-
getJavaxProviderMapKey
private Key<java.util.Map<K,javax.inject.Provider<V>>> getJavaxProviderMapKey()
-
getProviderSetMultimapKey
private Key<java.util.Map<K,java.util.Set<Provider<V>>>> getProviderSetMultimapKey()
-
getJavaxProviderSetMultimapKey
private Key<java.util.Map<K,java.util.Set<javax.inject.Provider<V>>>> getJavaxProviderSetMultimapKey()
-
getProviderCollectionMultimapKey
private Key<java.util.Map<K,java.util.Collection<Provider<V>>>> getProviderCollectionMultimapKey()
-
getJavaxProviderCollectionMultimapKey
private Key<java.util.Map<K,java.util.Collection<javax.inject.Provider<V>>>> getJavaxProviderCollectionMultimapKey()
-
getEntrySetJavaxProviderKey
private Key<java.util.Set<java.util.Map.Entry<K,javax.inject.Provider<V>>>> getEntrySetJavaxProviderKey()
-
getMultimapBindings
private com.google.common.collect.ImmutableMap<K,java.util.Set<Binding<V>>> getMultimapBindings()
-
getEntries
private com.google.common.collect.ImmutableList<java.util.Map.Entry<K,Binding<V>>> getEntries()
-
isInitialized
private boolean isInitialized()
-
getKeyType
private TypeLiteral<K> getKeyType()
-
getValueType
private TypeLiteral<V> getValueType()
-
getEntrySetBinder
private RealMultibinder<java.util.Map.Entry<K,Provider<V>>> getEntrySetBinder()
-
permitsDuplicates
private boolean permitsDuplicates()
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-