limpb...@gmail.com
unread,Aug 9, 2011, 1:38:55 AM8/9/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to google-guice
Looks like you've found a bug! Behind the scenes Guice is using a set
binder for the map's elements; unfortunately it isn't guarding this
from collision with similar sets.
I'll look into getting this fixed for our next release. In the
interim, you can workaround by using an annotation on your map binder.
Then bind the key you want (the unannotated map) to the key that you
have:
Injector injector = Guice.createInjector(new AbstractModule() {
@Override protected void configure() {
Multibinder.newSetBinder(binder(), String.class)
.addBinding().toInstance("A");
Named uniqueName = Names.named(UUID.randomUUID().toString());
MapBinder.newMapBinder(binder(), String.class, String.class,
uniqueName)
.addBinding("B").toInstance("b");
bind(new Key<Map<String, String>>() {}).to(new Key<Map<String,
String>>(uniqueName) {});
}
});
Cheers,
Jesse