My classes (let call them X
and Y
) both implementing Parser
interface do (relatively) CPU intensive operations to build parsers for certain syntaxes (different syntaxes for X
and Y
).
Now I want to inject (with Guice) dependencies of both X
and Y
into constructor of an (upper level) parser P
. Both arguments of P
should be of the type Parser
:
class P implements Parser {
@Inject
public P(Parser x, Parser y) {
// ...
}
}
How can I make Guice to differentiate which of the two arguments of P
shall receive X
and Y
?
As you understand, X
and Y
should be annotated @Singleton
(but this note seems unrelated with the question).