As a Multibinder, it acts as a factory for LinkedBindingBuilders for each of the set's elements. Each binding is given an annotation that identifies it as a part of this set.
As a Module, it installs the binding to the set itself. As a module, this implements equals() and hashcode() in order to trick Guice into executing its configure() method only once. That makes it so that multiple multibinders can be created for the same target collection, but only one is bound. Since the list of bindings is retrieved from the injector itself (and not the multibinder), each multibinder has access to all contributions from all multibinders.
As a Provider, this constructs the set instances.
We use a subclass to hide 'implements Module, Provider' from the public API.
Nested Class Summary
Method SummaryModifier and TypeMethodDescription
()Returns a binding builder used to add a new element in the set.
Binder binder)(Contributes bindings and other configurations for this module to
()Provides an instance of
()Returns the known dependencies for this type.
Injector injector)(Invoked by Guice at Injector-creation time to prepare providers for each element in this set.
Methods inherited from class org.elasticsearch.common.inject.multibindings.Multibinder
newSetBinder, newSetBinder, newSetBinder, newSetBinder, newSetBinder, newSetBinder
configurepublic void configure(Binder binder)Description copied from interface:
ModuleContributes bindings and other configurations for this module to
addBindingDescription copied from class:
MultibinderReturns a binding builder used to add a new element in the set. Each bound element must have a distinct value. Bound providers will be evaluated each time the set is injected.
It is an error to call this method without also calling one of the
tomethods on the returned binding builder.
Scoping elements independently is supported. Use the
inmethod to specify a binding scope.
initializeInvoked by Guice at Injector-creation time to prepare providers for each element in this set. At this time the set's size is known, but its contents are only evaluated when get() is invoked.
getDescription copied from interface:
ProviderProvides an instance of
T. Must never return
getDependenciesDescription copied from interface:
HasDependenciesReturns the known dependencies for this type. If this has dependencies whose values are not known statically, a dependency for the
Injectorwill be included in the returned set.
equalspublic boolean equals(Object o)
hashCodepublic int hashCode()
toStringpublic String toString()