T
- type of value for Setpublic final class GinMultibinder<T> extends Object
Example usage:
interface X {}; class X1Impl implements X {}; class X2Impl implements X {}; class X3Provider implements Provider<X> { ... }; Set<X> multibinder = GinMultibinder.newSetBinder(binder(), X.class); multibinder.addBinding().to(X1Impl.class); multibinder.addBinding().to(X2Impl.class); multibinder.addBinding().toProvier(X3Provider.class);
Constructor and Description |
---|
GinMultibinder(GinBinder ginBinder,
TypeLiteral<T> elementType,
Key<Provider<T>> keyForMultibinding) |
Modifier and Type | Method and Description |
---|---|
GinLinkedBindingBuilder<T> |
addBinding()
Returns a binding builder used to add a new element in the set.
|
static <T> GinMultibinder<T> |
newSetBinder(GinBinder binder,
Class<T> type)
Returns a new multibinder that collects instances of
type in a Set
that is itself bound with no binding annotation. |
static <T> GinMultibinder<T> |
newSetBinder(GinBinder binder,
Class<T> type,
Annotation annotation)
Returns a new multibinder that collects instances of
type in a Set
that is itself bound with annotation . |
static <T> GinMultibinder<T> |
newSetBinder(GinBinder binder,
Class<T> type,
Class<? extends Annotation> annotationType)
Returns a new multibinder that collects instances of
type in a Set that is
itself bound with annotationType . |
static <T> GinMultibinder<T> |
newSetBinder(GinBinder binder,
TypeLiteral<T> type)
Returns a new multibinder that collects instances of
type in a Set
that is itself bound with no binding annotation. |
static <T> GinMultibinder<T> |
newSetBinder(GinBinder binder,
TypeLiteral<T> type,
Annotation annotation)
Returns a new multibinder that collects instances of
type in a Set
that is itself bound with annotation . |
static <T> GinMultibinder<T> |
newSetBinder(GinBinder binder,
TypeLiteral<T> type,
Class<? extends Annotation> annotationType)
Returns a new multibinder that collects instances of
type in a Set
that is itself bound with annotationType . |
GinMultibinder<T> |
permitDuplicates()
Configures the bound set to silently discard duplicate elements.
|
public static <T> GinMultibinder<T> newSetBinder(GinBinder binder, TypeLiteral<T> type)
type
in a Set
that is itself bound with no binding annotation.public static <T> GinMultibinder<T> newSetBinder(GinBinder binder, Class<T> type)
type
in a Set
that is itself bound with no binding annotation.public static <T> GinMultibinder<T> newSetBinder(GinBinder binder, TypeLiteral<T> type, Annotation annotation)
type
in a Set
that is itself bound with annotation
.public static <T> GinMultibinder<T> newSetBinder(GinBinder binder, Class<T> type, Annotation annotation)
type
in a Set
that is itself bound with annotation
.public static <T> GinMultibinder<T> newSetBinder(GinBinder binder, TypeLiteral<T> type, Class<? extends Annotation> annotationType)
type
in a Set
that is itself bound with annotationType
.public static <T> GinMultibinder<T> newSetBinder(GinBinder binder, Class<T> type, Class<? extends Annotation> annotationType)
type
in a Set
that is
itself bound with annotationType
.public GinMultibinder<T> permitDuplicates()
public GinLinkedBindingBuilder<T> addBinding()
It is an error to call this method without also calling one of the to
methods on the
returned binding builder.
Scoping elements independently is supported. Use the in
method to specify a binding
scope.
Copyright © 2008–2018. All rights reserved.