If I read the example correctly. B does not need A. It just provides a method
to retrieve a new instance of A.
So A and B should really be 2 separate classes.
Am 23. Dezember 2014 03:10:12 MEZ, schrieb Tim Boudreau :
>What you have is a design problem. If A needs B to exist, and B needs
>A to
What you have is a design problem. If A needs B to exist, and B needs A to
exist, then either
- There is some other implicit object that provides data to both A and B,
or
- You really have one logical class, and your implementation is trying to
pretend it's two
The most straightforward way
The thing you are looking for is called assisted injection.
https://github.com/google/guice/wiki/AssistedInject
But often when you need to pass runtime values to an object created with guice.
The object is a mix between a data structure and a business object. Try to
separate them and the assiste
Hello all.
Lets say I have:
class A {
//...
}
class B {
A getA() {
// Building a A using B attributes
}
//...
}
I'd love to write:
class B {
private final a;
@Inject
private B(A a) {
this.a = a;
}
//...
}
But, since the building of the A instance relie