1

次のようなマルチバインディング コードがあります。

bind(SuperClass.class).annotatedWith(Names.named("Name1"))
                .to(SubClass1.class).in(Scopes.SINGLETON);
bind(SuperClass.class).annotatedWith(Names.named("Name2"))
                .to(SubClass2.class).in(Scopes.SINGLETON);
...another 20 lines of this stuff

次のようなコードもあります。

multiBinder.addBinding().to(SomeClass1.class)
                .in(Scopes.SINGLETON);
multiBinder.addBinding().to(SomeClass2.class)
                .in(Scopes.SINGLETON);
...another 20 lines of this stuff too

Guiceでこれをより少ない行/より少ない繰り返しで行う方法はありますか?

編集:「forループを使用して一連のキーを反復処理する」などの回答を探していません。

4

1 に答える 1