Class RealMultibinder<T>
- java.lang.Object
-
- com.google.inject.internal.RealMultibinder<T>
-
- All Implemented Interfaces:
Module
public final class RealMultibinder<T> extends Object implements Module
The actual multibinder plays several roles: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.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LinkedBindingBuilder<T>addBinding()voidconfigure(Binder binder)Contributes bindings and other configurations for this module tobinder.booleanequals(Object o)inthashCode()static <T> RealMultibinder<T>newRealSetBinder(Binder binder, Key<T> key)Implementation of newSetBinder.voidpermitDuplicates()
-
-
-
Method Detail
-
newRealSetBinder
public static <T> RealMultibinder<T> newRealSetBinder(Binder binder, Key<T> key)
Implementation of newSetBinder.
-
configure
public void configure(Binder binder)
Description copied from interface:ModuleContributes bindings and other configurations for this module tobinder.Do not invoke this method directly to install submodules. Instead use
Binder.install(Module), which ensures thatprovider methodsare discovered.
-
permitDuplicates
public void permitDuplicates()
-
addBinding
public LinkedBindingBuilder<T> addBinding()
-
-