@Documented @Target(value=METHOD) @Retention(value=RUNTIME) public @interface ProvidesIntoMap
Module
to add items to a MapBinder
.
The method's return type, binding annotation and additional key annotation determines
what Map this will contribute to. For example,
@ProvidesIntoMap @StringMapKey("Foo") @Named("plugins") Plugin provideFooUrl(FooManager fm) { return fm.getPlugin(); } @ProvidesIntoMap @StringMapKey("Bar") @Named("urls") Plugin provideBarUrl(BarManager bm) { return bm.getPlugin(); }will add two items to the
@Named("urls") Map<String, Plugin>
map. The key 'Foo'
will map to the provideFooUrl method, and the key 'Bar' will map to the provideBarUrl method.
The values are bound as providers and will be evaluated at injection time.
Because the key is specified as an annotation, only Strings, Classes, enums, primitive types and annotation instances are supported as keys.