Frage

We have a Multibinder and would like to have two so we need the @Named annotation so we can do

@Inject @Named("work")
private Set<Runnable> work;
@Inject @Named("otherWork");
private Set<Runnable> otherWork;

IS there a way to bind Multibinder with names?

thanks, Dean

War es hilfreich?

Lösung

Per this static factory and this helper method:

Multibinder<Runnable> multibinder = Multibinder.newSetBinder(
    binder(), Runnable.class, Names.named("work"));
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top