Hierarchy of modules in guice
Posted
by Niko
on Stack Overflow
See other posts from Stack Overflow
or by Niko
Published on 2010-05-24T21:29:49Z
Indexed on
2010/05/24
21:31 UTC
Read the original article
Hit count: 217
guice
Hi,
I'd like to run a unit test where a constant is slightly different than in the standard version. That is, in my default module, the following is
bindConstant().annotatedWith(Names.named("number of players")).to(4);
but in testing, I'd like to try this line instead:
bindConstant().annotatedWith(Names.named("number of players")).to(2);
Id like to achieve that without copying all of the rest of the module. What I really want is a "default" module that is "below" a more specialized module, such that in case of conflict, the specialized module wins (instead of throwing an exception, which is what guice does).
In essence, my question is: how does anybody arrange for more than one module without lots of code duplication?
© Stack Overflow or respective owner