Sorry... Clarification. You should annotate with nullable as you did, for clarity, but that is not all you need to do. If you don't bind the way I said the injector will throw a fit. A missing binding is not allowed in the same way as you might expect.
Regards, Christian Sent from my iPhone. On Jun 23, 2012, at 9:43, Christian Gruber <[email protected]> wrote: > No. Optional injection is only (currently) supported with > com.google.inject.Inject. What is your use case? If its injecting > nulls explicitly then you really want to bind to a null provider like > > Foo f = <something that might be null> > bind(Foo.class).to(Providers.of(f)); > > Or just: > > bind(Foo.class).to(Providers.of(null)); > > Do you have a different Use case in mind? > > Regards, > Christian > Sent from my iPhone. > > On Jun 23, 2012, at 8:53, "[email protected]" > <[email protected]> wrote: > >> Comment by [email protected]: >> >> is >> {{{ >> @javax.inject.Inject >> @javax.annotation.Nullable >> }}} >> equals to >> {{{ >> @com.google.inject.Inject(optional=true) >> }}} >> ? >> >> For more information: >> http://code.google.com/p/google-guice/wiki/Injections >> >> -- >> You received this message because you are subscribed to the Google Groups >> "google-guice-dev" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/google-guice-dev?hl=en. >> -- You received this message because you are subscribed to the Google Groups "google-guice-dev" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-guice-dev?hl=en.
