DeactivationFactoryMachine implements FactoryMachine { public static DeactivationFactoryMachine forNames(Iterable<Name<?>> names) { return new DeactivationFactoryMachine(names); } DeactivationFactoryMachine(Iterable<Name<?>> keys); static DeactivationFactoryMachine forNames(Iterable<Name<?>> names); static DeactivationFactoryMachine forNames(Name<?>... names); @Override boolean canBuild(Name<?> name); @Override MachineEngine<T> getEngine(Name<T> name); @Override Set<Name<T>> nameBuildableComponents(Class<T> componentClass); @Override int priority();  }
@Test public void should_deactivate_components() throws Exception { Name<Integer> one = Name.of(Integer.class, "one"); Name<Integer> two = Name.of(Integer.class, "two"); Factory factory = Factory.builder() .addMachine(new SingletonFactoryMachine<>(0, new NamedComponent(one, 1))) .addMachine(new SingletonFactoryMachine<>(0, new NamedComponent(two, 2))) .addMachine(DeactivationFactoryMachine.forNames(one)) .build(); assertThat(factory.getComponents(Integer.class)).containsExactly(2); }