private static final class RealMultibinder.ExtensionRealMultibinderProvider<T> extends RealMultibinder.BaseFactory<T,java.util.Set<T>> implements ProviderWithExtensionVisitor<java.util.Set<T>>, MultibinderBinding<java.util.Set<T>>
| Modifier and Type | Field and Description |
|---|---|
(package private) RealMultibinder.RealMultibinderProvider<T> |
delegate |
bindingSelection, dependenciesFnprovisionCallback| Constructor and Description |
|---|
ExtensionRealMultibinderProvider(RealMultibinder.RealMultibinderProvider<T> delegate) |
| Modifier and Type | Method and Description |
|---|---|
<B,V> V |
acceptExtensionVisitor(BindingTargetVisitor<B,V> 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 Multibinder uses the given Element.
|
protected void |
doInitialize() |
protected com.google.common.collect.ImmutableSet<T> |
doProvision(InternalContext context,
Dependency<?> dependency)
Creates an object to be injected.
|
com.google.common.collect.ImmutableSet<Key<?>> |
getAlternateSetKeys()
Returns the keys of other bindings that represent this set.
|
java.util.List<Binding<?>> |
getElements()
Returns all bindings that make up the set.
|
TypeLiteral<?> |
getElementTypeLiteral()
Returns the TypeLiteral that describes the type of elements in the set.
|
Key<java.util.Set<T>> |
getSetKey()
Returns the key for the set.
|
boolean |
permitsDuplicates()
Returns true if the multibinder permits duplicates.
|
equals, getDependencies, hashCode, initializeget, get, getSourcefinal RealMultibinder.RealMultibinderProvider<T> delegate
ExtensionRealMultibinderProvider(RealMultibinder.RealMultibinderProvider<T> delegate)
protected void doInitialize()
doInitialize in class RealMultibinder.BaseFactory<T,java.util.Set<T>>protected com.google.common.collect.ImmutableSet<T> doProvision(InternalContext context, Dependency<?> dependency) throws InternalProvisionException
InternalProviderInstanceBindingImpl.FactorydoProvision in class InternalProviderInstanceBindingImpl.Factory<java.util.Set<T>>InternalProvisionException - if a value cannot be providedpublic <B,V> V acceptExtensionVisitor(BindingTargetVisitor<B,V> 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.Set<T>>public Key<java.util.Set<T>> getSetKey()
MultibinderBindinggetSetKey in interface MultibinderBinding<java.util.Set<T>>public com.google.common.collect.ImmutableSet<Key<?>> getAlternateSetKeys()
MultibinderBindingCollection<com.google.inject.Provider<V>>, Collection<javax.inject.Provider<V>>, and Set<? extends V>.getAlternateSetKeys in interface MultibinderBinding<java.util.Set<T>>public TypeLiteral<?> getElementTypeLiteral()
MultibinderBindingThe elements will always match the type Set's generic type. For example, if getSetKey
returns a key of Set<String>, then this will always return a
TypeLiteral<String>.
getElementTypeLiteral in interface MultibinderBinding<java.util.Set<T>>public java.util.List<Binding<?>> getElements()
MultibinderBindingUnsupportedOperationException if it is called on an element
retrieved from Elements.getElements(com.google.inject.Module...).
The elements will always match the type Set's generic type. For example, if getSetKey
returns a key of Set<String>, then this will always return a list of type
List<Binding<String>>.
getElements in interface MultibinderBinding<java.util.Set<T>>public boolean permitsDuplicates()
MultibinderBindingUnsupportedOperationException if it is called on a
MultibinderBinding retrieved from Elements.getElements(com.google.inject.Module...).permitsDuplicates in interface MultibinderBinding<java.util.Set<T>>public boolean containsElement(Element element)
MultibinderBindingElements.getElements(com.google.inject.Module...).
Usually this is only necessary if you are working with elements retrieved from modules (without
an Injector), otherwise MultibinderBinding.getElements() and MultibinderBinding.permitsDuplicates() are better options.
If you need to introspect the details of the set, such as the values or if it permits
duplicates, it is necessary to pass the elements through an Injector and use MultibinderBinding.getElements() and MultibinderBinding.permitsDuplicates().
containsElement in interface MultibinderBinding<java.util.Set<T>>