private static final class RealMapBinder.RealMapProvider<K,V> extends RealMapBinder.RealMapBinderProviderWithDependencies<K,V,java.util.Map<K,V>> implements ProviderWithExtensionVisitor<java.util.Map<K,V>>, MapBinderBinding<java.util.Map<K,V>>
| Modifier and Type | Field and Description |
|---|---|
private java.util.Set<Dependency<?>> |
dependencies |
private SingleParameterInjector<V>[] |
injectors
An array of all the injectors.
|
private K[] |
keys |
bindingSelectionprovisionCallback| Modifier | Constructor and Description |
|---|---|
private |
RealMapProvider(RealMapBinder.BindingSelection<K,V> bindingSelection) |
| Modifier and Type | Method and Description |
|---|---|
<B,W> W |
acceptExtensionVisitor(BindingTargetVisitor<B,W> visitor,
ProviderInstanceBinding<? extends B> 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 MapBinder contains the given Element in order to build the map or uses the
given Element in order to support building and injecting the map.
|
protected void |
doInitialize(InjectorImpl injector,
Errors errors)
Initialize the factory.
|
protected java.util.Map<K,V> |
doProvision(InternalContext context,
Dependency<?> dependency)
Creates an object to be injected.
|
private RealMapBinder.BindingSelection<K,V> |
getBindingSelection() |
java.util.Set<Dependency<?>> |
getDependencies()
Returns the known dependencies for this type.
|
java.util.List<java.util.Map.Entry<?,Binding<?>>> |
getEntries()
Returns all entries in the Map.
|
java.util.List<java.util.Map.Entry<?,Binding<?>>> |
getEntries(java.lang.Iterable<? extends Element> elements)
Similar to
MapBinderBinding.getEntries(), but can be used on a MapBinderBinding retrieved from Elements.getElements(com.google.inject.Module...). |
TypeLiteral<K> |
getKeyTypeLiteral()
Returns the TypeLiteral describing the keys of the map.
|
Key<java.util.Map<K,V>> |
getMapKey()
Returns the
Key for the map. |
TypeLiteral<V> |
getValueTypeLiteral()
Returns the TypeLiteral describing the values of the map.
|
boolean |
permitsDuplicates()
Returns true if the MapBinder permits duplicates.
|
equals, hashCode, initializeget, get, getSourceprivate java.util.Set<Dependency<?>> dependencies
private SingleParameterInjector<V>[] injectors
This is parallel to array of keys below
private K[] keys
private RealMapProvider(RealMapBinder.BindingSelection<K,V> bindingSelection)
private RealMapBinder.BindingSelection<K,V> getBindingSelection()
protected void doInitialize(InjectorImpl injector, Errors errors) throws ErrorsException
RealMapBinder.RealMapBinderProviderWithDependenciesdoInitialize in class RealMapBinder.RealMapBinderProviderWithDependencies<K,V,java.util.Map<K,V>>ErrorsExceptionprotected java.util.Map<K,V> doProvision(InternalContext context, Dependency<?> dependency) throws InternalProvisionException
InternalProviderInstanceBindingImpl.FactorydoProvision in class InternalProviderInstanceBindingImpl.Factory<java.util.Map<K,V>>InternalProvisionException - if a value cannot be providedpublic java.util.Set<Dependency<?>> getDependencies()
HasDependenciesInjector will be
included in the returned set.getDependencies in interface HasDependenciespublic <B,W> W acceptExtensionVisitor(BindingTargetVisitor<B,W> visitor, ProviderInstanceBinding<? extends B> binding)
ProviderWithExtensionVisitorDue 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<java.util.Map<K,V>>public Key<java.util.Map<K,V>> getMapKey()
MapBinderBindingKey for the map.getMapKey in interface MapBinderBinding<java.util.Map<K,V>>public TypeLiteral<K> getKeyTypeLiteral()
MapBinderBindingThe TypeLiteral will always match the type Map's generic type. For example, if getMapKey
returns a key of Map<String, Snack>, then this will always return a
TypeLiteral<String>.
getKeyTypeLiteral in interface MapBinderBinding<java.util.Map<K,V>>public TypeLiteral<V> getValueTypeLiteral()
MapBinderBindingThe TypeLiteral will always match the type Map's generic type. For example, if getMapKey
returns a key of Map<String, Snack>, then this will always return a
TypeLiteral<Snack>.
getValueTypeLiteral in interface MapBinderBinding<java.util.Map<K,V>>public java.util.List<java.util.Map.Entry<?,Binding<?>>> getEntries()
MapBinderBindingUnsupportedOperationException if it is called on an element retrieved from Elements.getElements(com.google.inject.Module...).
The elements will always match the type Map's generic type. For example, if getMapKey
returns a key of Map<String, Snack>, then this will always return a list of
type List<Map.Entry<String, Binding<Snack>>>.
getEntries in interface MapBinderBinding<java.util.Map<K,V>>public java.util.List<java.util.Map.Entry<?,Binding<?>>> getEntries(java.lang.Iterable<? extends Element> elements)
MapBinderBindingMapBinderBinding.getEntries(), but can be used on a MapBinderBinding retrieved from Elements.getElements(com.google.inject.Module...).
One way to use this is to pass in the results of Elements.getElements(com.google.inject.Module...) as the elements parameter.
This differs from MapBinderBinding.getEntries() in that it will return duplicates if they are
present in the elements passed in. This does not run the normal Guice de-duplication
that MapBinderBinding.getEntries() does.
getEntries in interface MapBinderBinding<java.util.Map<K,V>>public boolean permitsDuplicates()
MapBinderBindingUnsupportedOperationException if it is called on a
MapBinderBinding retrieved from Elements.getElements(com.google.inject.Module...).permitsDuplicates in interface MapBinderBinding<java.util.Map<K,V>>public boolean containsElement(Element element)
MapBinderBindingElements.getElements(com.google.inject.Module...). Usually this is
only necessary if you are working with elements retrieved from modules (without an Injector),
otherwise MapBinderBinding.getEntries() and MapBinderBinding.permitsDuplicates() are better options.
If you need to introspect the details of the map, such as the keys, values or if it permits
duplicates, it is necessary to pass the elements through an Injector and use MapBinderBinding.getEntries() and MapBinderBinding.permitsDuplicates().
containsElement in interface MapBinderBinding<java.util.Map<K,V>>