google / google/guice

Versions of @ProvidesIntoSet, @ProvidesIntoMap which allow multiple bindings

Open
#1,096 1 comment 11 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
12.7k
Forks
1.7k
Avg merge
11m
Merged PRs (30d)
2

Description

Guice provides `@ProvidesIntoSet` and `@ProvidesIntoMap` to allow adding items to multibound `Set`s and `Map`s 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.