Status: New
Owner: ----

New issue 406 by [email protected]: Shortcuts in configuration
http://code.google.com/p/google-guice/issues/detail?id=406

In a module configuration could it be possible to implement some shortcuts
? I don't find it straight to think about all workarounds for these
builders, since they are not standardized.

Typically I would think of such examples:

bind(MyInterface.class).named("blah").to(MyClass.class);
bind(MyInterface.class).toFactory(MyFactory.class);
Multibinder<Snack> setBinder = setBinderOf(Snack.class);
MapBinder<String,Snack> mapBinder = mapBinderOf(String.class,Snack.class);

being shortcuts for

bind(MyInterface.class).annotatedWith(Names.named("blah")).to(MyClass.class);
bind(MyInterface.class).toProvider(FactoryProvider.newFactory(MyFactory.class,
MyInterface.class));
Multibinder<Snack> setBinder = Multibinder.newSetBinder(binder(),  
Snack.class);
MapBinder<String,Snack> mapBinder = MapBinder.newMapBinder(binder(),
String.class, Snack.class);

This last methods require indeed the assisted injection package, but can't
it simply be documented that we need that jar-file in the case where we
plan to use the that method? If I remember well, this is possible in Java.

With this kind of writing, we can even add some extension like:

setBinderOf(Snack.class).named("snacks").toFactory(...);
or
Multibinder<Snack> setBinder = setBinderOf(Snack.class).annotatedWith(...);
// setBinder.whatever()



--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-guice-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to