final class MapBinder.RealMapBinder.RealMapProvider extends MapBinder.RealMapBinder.RealMapWithExtensionProvider<java.util.Map<K,V>>
Modifier and Type | Field and Description |
---|---|
private com.google.common.collect.ImmutableSet<Dependency<?>> |
dependencies |
private Provider<java.util.Map<K,Provider<V>>> |
mapProvider |
Modifier | Constructor and Description |
---|---|
private |
RealMapProvider(com.google.common.collect.ImmutableSet<Dependency<?>> dependencies,
Provider<java.util.Map<K,Provider<V>>> mapProvider) |
Modifier and Type | Method and Description |
---|---|
<B,R> R |
acceptExtensionVisitor(BindingTargetVisitor<B,R> 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.
|
java.util.Map<K,V> |
get() |
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.
|
TypeLiteral<?> |
getKeyTypeLiteral()
Returns the TypeLiteral describing the keys of the map.
|
Key<java.util.Map<K,V>> |
getMapKey()
Returns the
Key for the map. |
TypeLiteral<?> |
getValueTypeLiteral()
Returns the TypeLiteral describing the values of the map.
|
boolean |
permitsDuplicates()
Returns true if the MapBinder permits duplicates.
|
equals, hashCode
private final com.google.common.collect.ImmutableSet<Dependency<?>> dependencies
private RealMapProvider(com.google.common.collect.ImmutableSet<Dependency<?>> dependencies, Provider<java.util.Map<K,Provider<V>>> mapProvider)
public java.util.Set<Dependency<?>> getDependencies()
HasDependencies
Injector
will be
included in the returned set.public <B,R> R acceptExtensionVisitor(BindingTargetVisitor<B,R> visitor, ProviderInstanceBinding<? extends B> binding)
ProviderWithExtensionVisitor
Due 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'.
public Key<java.util.Map<K,V>> getMapKey()
MapBinderBinding
Key
for the map.public TypeLiteral<?> getKeyTypeLiteral()
MapBinderBinding
The 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>
.
public TypeLiteral<?> getValueTypeLiteral()
MapBinderBinding
The 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>
.
public java.util.List<java.util.Map.Entry<?,Binding<?>>> getEntries()
MapBinderBinding
UnsupportedOperationException
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>>>
.
public boolean permitsDuplicates()
MapBinderBinding
UnsupportedOperationException
if it is called on a
MapBinderBinding retrieved from Elements.getElements(com.google.inject.Module...)
.public boolean containsElement(Element element)
MapBinderBinding
Elements.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()
.