I am attempting to implement some auxiliary EDSLs for accessing a
library through Guice. I am having trouble figuring out how to implement
.annotatedWith() in situations where the caller doesn't have to specify
an implementation.
This is easy enough to do when the library needs to consume a
mapping--one can have
reportBinder(binder).export(SomeClass.class);
throw into a multibinder a package local Mapping object containing a
field with Key.get(SomeClass.class) and defaults for other fields, then
.annotatedWith(...) can later replace that injection key field. Other
EDSL methods can later replace other fields to have non-default values.
So a caller could do:
reportBinder(binder).export(SomeClass.class).annotatedWith(SomeAnnotation.class).withTags(whatever);
What I can't figure out how to implement is the situation where I need
the EDSL to create a new binding.
reportBinder(binder).createReportCollection(SomeInterface.class);
needs to bind Key.get(SomeInterface.class) to some default
implementation the library constructs, but
reportBinder(binder).createReportCollection(SomeInterface.class).annotatedWith(SomeAnnotation.class);
needs to bind Key.get(SomeInterface.class, SomeAnnotation.class) to a
default implementation, but not provide any binding for
Key.get(SomeInterface.class).
Any suggestions for how to accomplish this?
--
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+unsubscr...@googlegroups.com.
To post to this group, send email to google-guice@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/56FAD4A2.8050302%40proofpoint.com.
For more options, visit https://groups.google.com/d/optout.