google / google/guice

Multibinder should accept bindings to sets of elements

Open
#662 0 comments 0 reactions 0 assignees View on GitHub
imported
Dominant language
Java
Stars
12.7k
Forks
1.7k
Avg merge
11m
Merged PRs (30d)
2

Description

_From [mattmccutchen@google.com](https://code.google.com/u/100074016002343462025/) on October 21, 2011 17:12:58_

Multibinder should accept bindings to sets whose size is not known until injector creation and then add all the elements of the sets to the multibound set.  Contrived example:

Multibinder.newSetBinder(binder(), User.class, MyAnnotation.class)
  .addSetBinding().toProvider(HappyEngineersProvider.class);

class HappyEngineersProvider implements Provider<Set<User>> {
  `@`Inject Company company;

  `@`Override public Set<User> get() {
    Set<User> happyEngineers = new HashSet<User>();
    for (User e : company.getEngineers())
      if (e.isHappy())
        happyEngineers.add(e);
    return happyEngineers;
  }
}

_Original issue: http://code.google.com/p/google-guice/issues/detail?id=662_

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.