Top Description Inners Fields Constructors Methods
com.google.inject.internal

public final Class RealMultibinder<T>

extends Object
implements Module
Class Inheritance
All Implemented Interfaces
com.google.inject.Module
Static Imports
com.google.inject.internal.Element.Type.MULTIBINDER, .Errors.checkConfiguration, .Errors.checkNotNull, com.google.inject.name.Names.named

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.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private abstract static class
RealMultibinder.BaseFactory<ValueT, ProvidedT>

Base implement of InternalProviderInstanceBindingImpl.Factory that works based on a BindingSelection, allowing provider instances for various bindings to be implemented with less duplication.

private static class
private static class
RealMultibinder.PermitDuplicatesModule

We install the permit duplicates configuration as its own binding, all by itself.

private static class
RealMultibinder.RealMultibinderCollectionOfProvidersProvider<T>

Implementation of BaseFactory that exposes a collection of providers of the values in the set.

private static class
RealMultibinder.RealMultibinderProvider<T>

Provider instance implementation that provides the actual set of values.

Field Summary

Modifier and TypeField and Description
private final Binder
private final RealMultibinder.BindingSelection<T>

Constructor Summary

AccessConstructor and Description
pack-priv
RealMultibinder(Binder binder, Key<T> key)

Method Summary

Modifier and TypeMethod and Description
public LinkedBindingBuilder<T>
pack-priv static <T> TypeLiteral<Collection<Provider<T>>>
pack-priv static <T> TypeLiteral<Collection<Provider<T>>>
public void
configure(Binder binder)

Implements com.google.inject.Module.configure.

Contributes bindings and other configurations for this module to binder.
pack-priv boolean
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
pack-priv TypeLiteral<T>
pack-priv Key<T>
getKeyForNewItem()

Adds a new entry to the set and returns the key for it.

pack-priv Key<Set<T>>
pack-priv String
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
public static <T> RealMultibinder<T>
newRealSetBinder(Binder binder, Key<T> key)

Implementation of newSetBinder.

public void
pack-priv boolean
pack-priv static <T> TypeLiteral<Set<T>>
setOf(TypeLiteral<T> elementType)

pack-priv static <T> TypeLiteral<Set<? extends T>>
setOfExtendsOf(TypeLiteral<T> elementType)

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait