I have a common interface like so:
trait Thing {
...
}
And implementations like so:
class ThingA extends Thing {
...
}
class ThingB extends Thing {
...
}
Which one to use is determined at runtime, so a pool is configured to provide the right one:
class Things(a: ThingA, b: ThingB) {
addThing(a)
addThing(b)
def getThing(x: String) = { ... }
}
How do I provide all configured Thing
s to the ThingPool without explicitly adding it to the constructor?
As in, I'd like to do the following:
class Things(pool: ThingPool) {
addThingsFromPool(pool)
def getThing(x: String) = { ... }
}
... where ThingPool
has all Thing
s without explicitly asking for them.
... or, ThingPool
could be a List[Thing]
.
The current state of things requires two additional edits to add a Thing
. I'd like to get to the point where all I need to do is add the binding statement in my Guice module.
I have omitted the annotations for clarity.