com.google.gwt.inject.client.multibindings
Class GinMultibinder<T>

java.lang.Object
  extended by com.google.gwt.inject.client.multibindings.GinMultibinder<T>
Type Parameters:
T - type of value for Set

public final class GinMultibinder<T>
extends java.lang.Object

A utility that mimics the behavior and API of Guice Multibinder for GIN.

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 Summary
GinMultibinder(GinBinder ginBinder, TypeLiteral<T> elementType, Key<Provider<T>> keyForMultibinding)
           
 
Method Summary
 GinLinkedBindingBuilder<T> addBinding()
          Returns a binding builder used to add a new element in the set.
static
<T> GinMultibinder<T>
newSetBinder(GinBinder binder, java.lang.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, java.lang.Class<T> type, java.lang.annotation.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, java.lang.Class<T> type, java.lang.Class<? extends java.lang.annotation.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, java.lang.annotation.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, java.lang.Class<? extends java.lang.annotation.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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GinMultibinder

public GinMultibinder(GinBinder ginBinder,
                      TypeLiteral<T> elementType,
                      Key<Provider<T>> keyForMultibinding)
Method Detail

newSetBinder

public 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.


newSetBinder

public static <T> GinMultibinder<T> newSetBinder(GinBinder binder,
                                                 java.lang.Class<T> type)
Returns a new multibinder that collects instances of type in a Set that is itself bound with no binding annotation.


newSetBinder

public static <T> GinMultibinder<T> newSetBinder(GinBinder binder,
                                                 TypeLiteral<T> type,
                                                 java.lang.annotation.Annotation annotation)
Returns a new multibinder that collects instances of type in a Set that is itself bound with annotation.


newSetBinder

public static <T> GinMultibinder<T> newSetBinder(GinBinder binder,
                                                 java.lang.Class<T> type,
                                                 java.lang.annotation.Annotation annotation)
Returns a new multibinder that collects instances of type in a Set that is itself bound with annotation.


newSetBinder

public static <T> GinMultibinder<T> newSetBinder(GinBinder binder,
                                                 TypeLiteral<T> type,
                                                 java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Returns a new multibinder that collects instances of type in a Set that is itself bound with annotationType.


newSetBinder

public static <T> GinMultibinder<T> newSetBinder(GinBinder binder,
                                                 java.lang.Class<T> type,
                                                 java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Returns a new multibinder that collects instances of type in a Set that is itself bound with annotationType.


permitDuplicates

public GinMultibinder<T> permitDuplicates()
Configures the bound set to silently discard duplicate elements. When multiple equal values are bound, the one that gets included is arbitrary. When multiple modules contribute elements to the set, this configuration option impacts all of them.


addBinding

public GinLinkedBindingBuilder<T> addBinding()
Returns 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 to methods on the returned binding builder.

Scoping elements independently is supported. Use the in method to specify a binding scope.