Hello, I think you need one setter per property. (this is the traditional JavaBeans convention in fact)
Anthony 2010/7/2 Jeremy Chone <[email protected]> > Let's say I would like to be able to optionally inject the three > following via Google Guice @Named inject. > > - webServiceUrl > - webServiceUsername > - webServicePassword > > But I do not want to require to have all the values in the property > map. I thought that @Inject(optional = true) and @Nullable would be my > friend, however, when I do the following, this inject method get > called only if all three properties are present in the property map. > > @Inject(optional = true) > public void injectWebServiceProperties( > @Nullable > @Named("akui.webServiceURL") String webServiceUrl, > @Nullable > @Named("akui.webServiceUsername") String webServiceUsername, > @Nullable > @Named("akui.webServicePassword") String webServicePassword) { > > if (webServiceUrl != null){ > ... > } > > if (webServiceUsername != null){ > ... > } > if (webServicePassword != null){ > ... > } > > } > > So, to make each property truly optional I need to have one setter per > property. > > > Is this a wanted feature or a bug? Is there any way to avoid to have > one setter per property while keeping any of them optional? > > > > Jeremy, > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-guice%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-guice?hl=en. > > -- You received this message because you are subscribed to the Google Groups "google-guice" 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?hl=en.
