public interface

MultibinderBinding

com.google.inject.multibindings.MultibinderBinding<T>

Class Overview

A binding for a Multibinder.

Summary

Public Methods
abstract boolean containsElement(Element element)
Returns true if this Multibinder uses the given Element.
abstract TypeLiteral<?> getElementTypeLiteral()
Returns the TypeLiteral that describes the type of elements in the set.
abstract List<Binding<?>> getElements()
Returns all bindings that make up the set.
abstract Key<T> getSetKey()
Returns the key for the set.
abstract boolean permitsDuplicates()
Returns true if the multibinder permits duplicates.

Public Methods

public abstract boolean containsElement (Element element)

Returns 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 and getElements(Module...). Usually this is only necessary if you are working with elements retrieved from modules (without an Injector), otherwise getElements() and 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 getElements() and permitsDuplicates().

public abstract TypeLiteral<?> getElementTypeLiteral ()

Returns 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 a TypeLiteral<String>.

public abstract List<Binding<?>> getElements ()

Returns all bindings that make up the set. This is only supported on bindings returned from an injector. This will throw UnsupportedOperationException if it is called on an element retrieved from getElements(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>>.

public abstract Key<T> getSetKey ()

Returns the key for the set.

public abstract boolean permitsDuplicates ()

Returns true if the multibinder permits duplicates. This is only supported on bindings returned from an injector. This will throw UnsupportedOperationException if it is called on a MultibinderBinding retrieved from getElements(Module...).