You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to google...@googlegroups.com
Is there a way to get an optional provider from a binder (same functionality of @Inject(optional = true))?
I have a case where I'm given an arbitrary binding annotation (I'm given the class), and I need to grab a provider for an optionally bound type with that binding annotation.
Thanks,
Daniel
Daniel Murphy
unread,
May 10, 2012, 5:36:08 PM5/10/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to google...@googlegroups.com
Just solved this by having the provider have an Injector dependency for HasDependencies, and then made an @Inject void initialize(Injector inj) method that uses inj.getExistingBinding(Key), which I then could then check if it was null. Ends up not being a static binding, but that makes sense because you wouldn't know if it's available or not until the whole graph is built.
It would be nice to grab an optional provider from the binder, is that a feasible feature request?