@Test public void command_binds_work() { final Command command = mock(Command.class); final Class<TestCommand> commandClass = TestCommand.class; Injector injector = Guice.createInjector(new AbstractPlugin() { @Override protected void configure() { bindCommand(command); bindCommand(commandClass); } }); Set<Command> commandSet = injector.getInstance(Keys.Commands); Set<Class<? extends Command>> commandClassSet = injector.getInstance(Keys.CommandClasses); assertThat(commandSet, hasSize(1)); assertThat(commandSet, hasItem(command)); assertThat(commandClassSet, hasSize(1)); assertThat(commandClassSet, hasItem(TestCommand.class)); }
protected void bindCommand(Command command) { Preconditions.checkNotNull(command, "Command cannot be null."); buildBinders(); commandBinder.addBinding().toInstance(command); }
AbstractPlugin extends AbstractModule implements Plugin { protected void bindCommand(Command command) { Preconditions.checkNotNull(command, "Command cannot be null."); buildBinders(); commandBinder.addBinding().toInstance(command); } }
AbstractPlugin extends AbstractModule implements Plugin { protected void bindCommand(Command command) { Preconditions.checkNotNull(command, "Command cannot be null."); buildBinders(); commandBinder.addBinding().toInstance(command); }  }
AbstractPlugin extends AbstractModule implements Plugin { protected void bindCommand(Command command) { Preconditions.checkNotNull(command, "Command cannot be null."); buildBinders(); commandBinder.addBinding().toInstance(command); }   }
AbstractPlugin extends AbstractModule implements Plugin { protected void bindCommand(Command command) { Preconditions.checkNotNull(command, "Command cannot be null."); buildBinders(); commandBinder.addBinding().toInstance(command); }    }