ReflectiveModuleInstantiationModule extends AbstractModule { @Nonnull public static Module getModuleForModuleNamesString(@Nullable String moduleNames) { if (moduleNames != null) { return new ReflectiveModuleInstantiationModule( Lists.newArrayList(moduleNames.split(","))); } return new AbstractModule() { @Override protected void configure() { } }; } ReflectiveModuleInstantiationModule(List<String> moduleClasses); @Nonnull static Module getModuleForModuleNamesString(@Nullable String moduleNames);  }
@Test public void testStaticStringHelperMethodTwoModules() { Injector injector = Guice.createInjector(Stage.PRODUCTION, new AbstractModule() { @Override protected void configure() { binder().requireExplicitBindings(); install(getModuleForModuleNamesString(PublicCtor.class.getName() + "," + PublicCtor2.class.getName())); } }); injector.getInstance(BindTarget.class); injector.getInstance(Key.get(BindTarget.class, Names.named("foo"))); }
@Test public void testStaticStringHelperMethodOneModule() { Injector injector = Guice.createInjector(Stage.PRODUCTION, new AbstractModule() { @Override protected void configure() { binder().requireExplicitBindings(); install(getModuleForModuleNamesString(PublicCtor.class.getName())); } }); injector.getInstance(BindTarget.class); }
@Test public void testStaticStringHelperMethodNull() { Guice.createInjector(Stage.PRODUCTION, new AbstractModule() { @Override protected void configure() { binder().requireExplicitBindings(); install(getModuleForModuleNamesString(null)); } }); }