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.ObjectThe 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
KtoBinding<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.RealMapProviderto 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 classRealMapBinder.BindingSelection.InitializationState
-
Field Summary
Fields Modifier and Type Field Description private com.google.common.collect.ImmutableList<java.util.Map.Entry<K,Binding<V>>>entriesprivate RealMultibinder<java.util.Map.Entry<K,Provider<V>>>entrySetBinderprivate Key<java.util.Set<java.util.Map.Entry<K,javax.inject.Provider<V>>>>entrySetJavaxProviderKeyprivate RealMapBinder.BindingSelection.InitializationStateinitializationStateprivate Key<java.util.Map<K,java.util.Collection<javax.inject.Provider<V>>>>javaxProviderCollectionMultimapKeyprivate Key<java.util.Map<K,javax.inject.Provider<V>>>javaxProviderMapKeyprivate Key<java.util.Map<K,java.util.Set<javax.inject.Provider<V>>>>javaxProviderSetMultimapKeyprivate TypeLiteral<K>keyTypeprivate com.google.common.collect.ImmutableMap<K,Binding<V>>mapBindingsThese are built during initialization and used by all factories to actually provide the relevant maps.private Key<java.util.Map<K,V>>mapKeyprivate com.google.common.collect.ImmutableMap<K,java.util.Set<Binding<V>>>multimapBindingsprivate Key<java.util.Map<K,java.util.Set<V>>>multimapKeyprivate booleanpermitsDuplicatesIndicates if this Map permits duplicates.private Key<java.util.Map<K,java.util.Collection<Provider<V>>>>providerCollectionMultimapKeyprivate Key<java.util.Map<K,Provider<V>>>providerMapKeyprivate Key<java.util.Map<K,java.util.Set<Provider<V>>>>providerSetMultimapKeyprivate TypeLiteral<V>valueType
-
Constructor Summary
Constructors Modifier Constructor Description privateBindingSelection(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 booleancontainsElement(Element element)booleanequals(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()inthashCode()private booleanisInitialized()private booleanmatchesValueKey(Key<?> key)Returns true if the key indicates this is a value in the map.private booleanpermitsDuplicates()private static <K,V>
voidreportDuplicateKeysError(com.google.common.collect.Multimap<K,Binding<V>> duplicates, Errors errors)private booleantryInitialize(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:
trueif initialization was successful,falseif 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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-