On May 22, 6:09 pm, "
christopher.oestl...@gmail.com"
<
christopher.oestl...@gmail.com> wrote:
> That feels a bit ugly. Is there a prettier way where I can just
> conditionally inside a provider (or similar) based on my settings
> class chose what modules to create my injectors with?
You should just use plain old Java code. The if statement is the
simplest way to do conditional stuff, and since Guice is configured
via plain code, this is easy:
public static void main(String[] args) {
List<String> argsList = Arrays.asList(args);
List<Module> modules = new ArrayList<Module>();
modules.add(new SettingsModule());
modules.add(new PersistenceModule());
if (argsList.contains("--use_renderer")) {
modules.add(new RenderModule());
}
Injector injector = Guice.createInjector(modules);
injector.getInstance(Service.class).start();
}