### Question:
AbstractPlugin extends AbstractModule implements Plugin { protected void bindTask(Task task) { Preconditions.checkNotNull(task, "Task cannot be null."); buildBinders(); taskBinder.addBinding().toInstance(task); }    }### Answer:
@Test public void task_binds_work() { final Task task = mock(Task.class); final Class<TestTask> taskClass = TestTask.class; Injector injector = Guice.createInjector(new AbstractPlugin() { @Override protected void configure() { bindTask(task); bindTask(taskClass); } }); Set<Task> taskSet = injector.getInstance(Keys.Tasks); Set<Class<? extends Task>> taskClassSet = injector.getInstance(Keys.TaskClasses); assertThat(taskSet, hasSize(1)); assertThat(taskSet, hasItem(task)); assertThat(taskClassSet, hasSize(1)); assertThat(taskClassSet, hasItem(TestTask.class)); }