Class 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 to Binding<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 in RealMapBinder.RealMultimapBinderProviderWithDependencies. This is done to avoid confusion because the BindingSelection contains mutable state.

    • Field Detail

      • mapKey

        private final Key<java.util.Map<K,​V>> mapKey
      • javaxProviderMapKey

        private Key<java.util.Map<K,​javax.inject.Provider<V>>> javaxProviderMapKey
      • providerMapKey

        private Key<java.util.Map<K,​Provider<V>>> providerMapKey
      • multimapKey

        private Key<java.util.Map<K,​java.util.Set<V>>> multimapKey
      • 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
      • 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
      • entries

        private com.google.common.collect.ImmutableList<java.util.Map.Entry<K,​Binding<V>>> entries
      • 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.
    • 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.
      • getProviderMapKey

        private Key<java.util.Map<K,​Provider<V>>> getProviderMapKey()
      • getJavaxProviderMapKey

        private Key<java.util.Map<K,​javax.inject.Provider<V>>> getJavaxProviderMapKey()
      • getMultimapKey

        private Key<java.util.Map<K,​java.util.Set<V>>> getMultimapKey()
      • 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()
      • getMapBindings

        private com.google.common.collect.ImmutableMap<K,​Binding<V>> getMapBindings()
      • 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()
      • getMapKey

        private Key<java.util.Map<K,​V>> getMapKey()
      • permitsDuplicates

        private boolean permitsDuplicates()
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object