bind(Apple.class).in(Singleton.class);
bind(Banana.class).in(Singleton.class);
bind(Grape.class).in(Singleton.class);
Multibindings are the way Guice is implementing plug-in
mechanism.
The best I can think of is having a single SetBinder and add all
pluggable classes there.
Then implement your own methods which iterate over all binded
classes and filter for the criteria you need.
class Fruity {
@Inject Set<Object> fruits;
Set<HasSeed> getAllFruitsWithSeed() {
Set<HasSeed> result = new HashSet<>();
for (Object candidate : fruits) {
if (candidate instanceof HasSeed) {
result.add((HasSeed) candidate);
}
}
}
--
You received this message because you are subscribed to the Google Groups "google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-guice...@googlegroups.com.
To post to this group, send email to google...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-guice.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/7e728a22-0d39-44a1-852e-b2dc2a62909a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.