SequentialIndividualCompleter implements IndividualCompleter { protected void decode(Individual individual) { State state = individual.getState(); if (state == State.GENOTYPED) { individual.setState(State.DECODING); Genotype genotype = individual.getGenotype(); Object phenotype = decoder.decode(genotype); individual.setPhenotype(phenotype); } else { throw new IllegalStateException("Cannot decode Individual, current state: " + state); } } @Inject  SequentialIndividualCompleter(Control control, Decoder<Genotype, Object> decoder,
			Evaluator<Object> evaluator); @Override void complete(Iterable<? extends Individual> iterable); @Override void complete(Individual... individuals);  }
@Test public void decode() throws TerminationException { Injector injector = Guice.createInjector(new MockProblemModule()); IndividualFactory factory = injector.getInstance(IndividualFactory.class); Individual i1 = factory.create(); SequentialIndividualCompleter completer = injector.getInstance(SequentialIndividualCompleter.class); Assert.assertTrue(i1.getState().equals(State.GENOTYPED)); completer.decode(i1); Assert.assertTrue(i1.getState().equals(State.PHENOTYPED)); Assert.assertTrue(i1.getPhenotype() == object); }
@Test(expected = IllegalStateException.class) public void decodePhenotyped() throws TerminationException { Injector injector = Guice.createInjector(new MockProblemModule()); IndividualFactory factory = injector.getInstance(IndividualFactory.class); Individual i1 = factory.create(); SequentialIndividualCompleter completer = injector.getInstance(SequentialIndividualCompleter.class); completer.decode(i1); completer.decode(i1); }