I have the following classes
public class X {
@Inject
public X(B b){}
}
public class A {
@Inject
public A(B b){}
}
public class B {
@Inject
public B(String c){}
}
public abstract AppModule {
@Binds
abstract A bindA(A a);
@Binds
abstract B bindB(B a);
@Provide
static String stringForX(){
return "oneX";
}
@Provide
static String stringForA(){
return "twoA";
}
}
Now B is injected into A and X. But the instance of B to be injected in X and A has to be internally injected with different Strings (stringForX() and stringForA(), respectively) How can i achieve this? I know @Named could be used but i am not sure how exactly in this particular case since B is common amongst them.
Thanks