Annotation Type ProvidesIntoMap


  • @Documented
    @Target(METHOD)
    @Retention(RUNTIME)
    @Keep
    public @interface ProvidesIntoMap
    Annotates methods of a 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("plugins")
     Plugin provideBarUrl(BarManager bm) { return bm.getPlugin(); }
     
    will add two items to the @Named("plugins") 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.

    Since:
    4.0