@Inject
void setSomething(@Optional Something something) {
// do something with something
}
}
I want this method to be called only if I've placed something in the context to be injected. Trouble is, when I construct a MyClass, a Something gets constructed to satisfy the injection. That's not what I want. How can I make this truly optional so that DI won't default construct something in order to call it? I'd settle for a call to setSomething(null).