@Test public void configuration_binds_work() { final TestConfiguration testConfiguration = new TestConfiguration(); Injector injector = Guice.createInjector(new AbstractPlugin() { @Override protected void configure() { bindConfiguration(TestConfiguration.class).toInstance(testConfiguration); } }); TestConfiguration actualConfiguration = injector.getInstance(Key.get(TestConfiguration.class)); assertThat(actualConfiguration, is(testConfiguration)); }
protected <T extends Configuration> ConfigurationBinder<T> bindConfiguration(Class<T> configurationClass) { Preconditions.checkNotNull(configurationClass, "Configuration Class cannot be null."); return ConfigurationBinder.forClass(configurationClass, binder()); }
AbstractPlugin extends AbstractModule implements Plugin { protected <T extends Configuration> ConfigurationBinder<T> bindConfiguration(Class<T> configurationClass) { Preconditions.checkNotNull(configurationClass, "Configuration Class cannot be null."); return ConfigurationBinder.forClass(configurationClass, binder()); } }
AbstractPlugin extends AbstractModule implements Plugin { protected <T extends Configuration> ConfigurationBinder<T> bindConfiguration(Class<T> configurationClass) { Preconditions.checkNotNull(configurationClass, "Configuration Class cannot be null."); return ConfigurationBinder.forClass(configurationClass, binder()); }  }
AbstractPlugin extends AbstractModule implements Plugin { protected <T extends Configuration> ConfigurationBinder<T> bindConfiguration(Class<T> configurationClass) { Preconditions.checkNotNull(configurationClass, "Configuration Class cannot be null."); return ConfigurationBinder.forClass(configurationClass, binder()); }   }
AbstractPlugin extends AbstractModule implements Plugin { protected <T extends Configuration> ConfigurationBinder<T> bindConfiguration(Class<T> configurationClass) { Preconditions.checkNotNull(configurationClass, "Configuration Class cannot be null."); return ConfigurationBinder.forClass(configurationClass, binder()); }    }