質問

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

役に立ちましたか?

解決

Per this static factory and this helper method:

Multibinder<Runnable> multibinder = Multibinder.newSetBinder(
    binder(), Runnable.class, Names.named("work"));
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top