Say I have custom type annotations @Classic and @Custom and I have annotated classes BarClassic and BarCustom which both implement interface Bar.
Then say I have another class BarUser where Bar is injected in constructor.
public class BarUser {
@Inject
private BarUser (Bar bar) {
...
}
And a class Foo where I would like to inject BarUser, but would like to specify to use say BarClassic within the injected BarUser.
Is there a way to this with annotations. So what I would like is:
public class Foo {
@Inject
@Classic
private BarUser barUser;
....
And with this I want to specify that the Bar injected within the BarUser should be the @Classic one. And maybe in another class do:
public class DifferentFoo {
@Inject
@Custom
private BarUser barUser;
....
Is the only way to this to have two different BarUser classes as well or is there some magic I could use?