Hi,
@Inject(optional=true) allows for optional properties, however if one
or more of the arguments are not defined, then the method will not be
called. This is forcing me to have a separate method for each optional
properties (too verbose for my taste).
Is there an easier way to support multiple optional arguments?
Here is the specific use case:
Let's say I have a DBHelper object, that can take two properties,
connectString and schema. They can be both optional (the default value
will be hardcoded).
I can do that easily today with:
@Inject(optional=true)
public void injectConnectString(@Nullable @Named("connectString")
String connectString){
....
}
@Inject(optional=true)
public void injectSchema(@Nullable @Named("schema")String schema){
....
}
However, for simplicity, I would like to have the same method for
both, like:
@Inject(optional=true)
public void injectDbConfig(@Nullable @Named("connectString")String
connectString, @Nullable @Named("schema")String schema){
Unfortunately, when i do this, if one of the param is not set in the
properties then the injectDbConfig won't be called.
Any suggestion. Is there an @Optional at the param level?
Thank you in advance.
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].
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.