Skip to content

Versions of @ProvidesIntoSet, @ProvidesIntoMap which allow multiple bindings #1096

@gabbard

Description

@gabbard

Guice provides @ProvidesIntoSet and @ProvidesIntoMap to allow adding items to multibound Sets and Maps using provider methods. However, using this approach, only a single item may be added to the multibound collection for each provider method and for maps the key must be known at compile-time.

It would be helpful if there were annotations like @ProvidesAllIntoSet and @ProvidesAllIntoMap which could indicate the returned collections should be merged with the multibound collections (via addAll or putAll).

My use case for this is that the map bindings I wish to create are themselves determined by another injected map. This also has the advantage of allowing the use of provider methods for Map multibindings with non-String keys.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions