Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multibinder should accept bindings to sets of elements #662

Open
gissuebot opened this issue Jul 7, 2014 · 0 comments
Open

Multibinder should accept bindings to sets of elements #662

gissuebot opened this issue Jul 7, 2014 · 0 comments
Labels

Comments

@gissuebot
Copy link

From mattmccutchen@google.com 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant