Class RealMultibinder.RealMultibinderProvider<T>
- All Implemented Interfaces:
InternalFactory<Set<T>>,MultibinderBinding<Set<T>>,Provider<Set<T>>,HasDependencies,ProviderWithExtensionVisitor<Set<T>>,javax.inject.Provider<Set<T>>
- Enclosing class:
- RealMultibinder<T>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final RealMultibinder.BindingSelection<T>private SingleParameterInjector<T>[]private booleanFields inherited from class com.google.inject.internal.InternalProviderInstanceBindingImpl.Factory
provisionCallback -
Constructor Summary
ConstructorsConstructorDescriptionRealMultibinderProvider(RealMultibinder.BindingSelection<T> bindingSelection) -
Method Summary
Modifier and TypeMethodDescription<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.booleancontainsElement(Element element) Returns true if this Multibinder uses the given Element.doProvision(InternalContext context, Dependency<?> dependency) Creates an object to be injected.booleanReturns the keys of other bindings that represent this set.Set<Dependency<?>>Returns the known dependencies for this type.Returns all bindings that make up the set.TypeLiteral<?>Returns the TypeLiteral that describes the type of elements in the set.Returns the key for the set.inthashCode()(package private) voidinitialize(InjectorImpl injector, Errors errors) A callback that allows for implementations to fetch dependencies on other bindings.private InternalProvisionExceptionnewDuplicateValuesException(com.google.common.collect.ImmutableSet<T> set, T[] values) private InternalProvisionExceptionnewNullEntryException(int i) booleanReturns true if the multibinder permits duplicates.Methods inherited from class com.google.inject.internal.InternalProviderInstanceBindingImpl.Factory
get, get, getSource
-
Field Details
-
bindingSelection
-
bindings
-
injectors
-
permitDuplicates
private boolean permitDuplicates
-
-
Constructor Details
-
RealMultibinderProvider
RealMultibinderProvider(RealMultibinder.BindingSelection<T> bindingSelection)
-
-
Method Details
-
getDependencies
Description copied from interface:HasDependenciesReturns the known dependencies for this type. If this has dependencies whose values are not known statically, a dependency for theInjectorwill be included in the returned set.- Specified by:
getDependenciesin interfaceHasDependencies- Returns:
- a possibly empty set
-
initialize
Description copied from class:InternalProviderInstanceBindingImpl.FactoryA callback that allows for implementations to fetch dependencies on other bindings.Will be called exactly once, prior to any call to
InternalProviderInstanceBindingImpl.Factory.doProvision(com.google.inject.internal.InternalContext, com.google.inject.spi.Dependency<?>).- Specified by:
initializein classInternalProviderInstanceBindingImpl.Factory<Set<T>>- Throws:
ErrorsException
-
doProvision
protected Set<T> doProvision(InternalContext context, Dependency<?> dependency) throws InternalProvisionException Description copied from class:InternalProviderInstanceBindingImpl.FactoryCreates an object to be injected.- Specified by:
doProvisionin classInternalProviderInstanceBindingImpl.Factory<Set<T>>- Returns:
- instance to be injected
- Throws:
InternalProvisionException- if a value cannot be provided
-
newNullEntryException
-
acceptExtensionVisitor
public <B,V> V acceptExtensionVisitor(BindingTargetVisitor<B, V> visitor, ProviderInstanceBinding<? extends B> binding) Description copied from interface:ProviderWithExtensionVisitorInstructs the extension determine if the visitor is an instance of a custom extension visitor, and if so, visit it using that method. If the visitor is not an instance of the custom extension visitor, this method MUST call visitor.visit(binding).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'.
- Specified by:
acceptExtensionVisitorin interfaceProviderWithExtensionVisitor<T>
-
newDuplicateValuesException
private InternalProvisionException newDuplicateValuesException(com.google.common.collect.ImmutableSet<T> set, T[] values) -
equals
-
hashCode
public int hashCode() -
getSetKey
Description copied from interface:MultibinderBindingReturns the key for the set.- Specified by:
getSetKeyin interfaceMultibinderBinding<T>
-
getAlternateSetKeys
Description copied from interface:MultibinderBindingReturns the keys of other bindings that represent this set. This will return an entry forCollection<com.google.inject.Provider<V>>andCollection<javax.inject.Provider<V>>.- Specified by:
getAlternateSetKeysin interfaceMultibinderBinding<T>
-
getElementTypeLiteral
Description copied from interface:MultibinderBindingReturns the TypeLiteral that describes the type of elements in the set.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 aTypeLiteral<String>.- Specified by:
getElementTypeLiteralin interfaceMultibinderBinding<T>
-
getElements
Description copied from interface:MultibinderBindingReturns all bindings that make up the set. This is only supported on bindings returned from an injector. This will throwUnsupportedOperationExceptionif it is called on an element retrieved fromElements.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 typeList<Binding<String>>.- Specified by:
getElementsin interfaceMultibinderBinding<T>
-
permitsDuplicates
public boolean permitsDuplicates()Description copied from interface:MultibinderBindingReturns true if the multibinder permits duplicates. This is only supported on bindings returned from an injector. This will throwUnsupportedOperationExceptionif it is called on a MultibinderBinding retrieved fromElements.getElements(com.google.inject.Module...).- Specified by:
permitsDuplicatesin interfaceMultibinderBinding<T>
-
containsElement
Description copied from interface:MultibinderBindingReturns true if this Multibinder uses the given Element. This will be true for bindings that derive the elements of the set and other bindings that Multibinder uses internally. This will work for MultibinderBindings retrieved from an injector andElements.getElements(com.google.inject.Module...). Usually this is only necessary if you are working with elements retrieved from modules (without an Injector), otherwiseMultibinderBinding.getElements()andMultibinderBinding.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()andMultibinderBinding.permitsDuplicates().- Specified by:
containsElementin interfaceMultibinderBinding<T>
-