GEIndividual extends AbstractIndividual { public Individual clone() { GEIndividual ind = new GEIndividual(this); ind.setPreviouslyUsedCodons(this.usedCodons); ind.invalidate(); return ind; } GEIndividual();  GEIndividual(GEGrammar g, Phenotype p, Genotype gen, Fitness f); private  GEIndividual(GEIndividual i); static GEIndividual getIndividual(final GEGrammar grammar, final Phenotype phen, final Genotype genotype, final Fitness fitness); void revalidate(GEIndividual ind); void invalidate(); boolean isMapped(); void setMapped(boolean mapped); boolean isValid(); void setValid(boolean b); boolean wasPreviouslyValid(); void setUsedCodons(int usedCodons); void setUsedWraps(int usedWraps); void map(int map); String getPhenotypeString(int map); Genotype getGenotype(); Mapper getMapper(); void setMapper(Mapper m); void setGenotype(Genotype g); void setPhenotype(Phenotype p); Phenotype getPhenotype(); Individual clone(); @Override String toString(); int getUsedCodons(); void setPreviouslyUsedCodons(int previouslyUsedCodons); int getPreviouslyUsedCodons(); int getUsedWraps(); int[] getCrossoverPoints(); int[] getMutationPoints(); ArrayList<Fitness> getParents(); void setCrossoverPoints(int[] crossoverPoints); void setMutationPoints(int[] mutationPoints); void setParents(ArrayList<Fitness> parents);  }
@Test public void testClone() { System.out.println("* GEIndividualTest: clone"); gei.map(0); gei.getFitness().setDouble(0.0); GEGrammar geg = new GEGrammar(); GEIndividual copy = (GEIndividual) gei.clone(); assertNotSame(copy, gei); assertEquals(false, copy == gei); assertEquals(true, copy.getGenotype().get(0).toString().equals(gei.getGenotype().get(0).toString())); assertNotSame(copy.getGenotype(), gei.getGenotype()); assertNotSame(copy.getFitness(), gei.getFitness()); assertEquals(true, copy.getFitness().getDouble() == gei.getFitness().getDouble()); assertEquals(false, copy.isMapped()); assertEquals(false, copy.isMapped() == gei.isMapped()); assertEquals(false, copy.isValid()); assertEquals(false, copy.isValid() == gei.isValid()); assertEquals(-1, copy.getUsedCodons()); assertEquals(true, copy.getUsedCodons() != gei.getUsedCodons()); assertEquals(-1, copy.getUsedWraps()); assertEquals(true, copy.getUsedWraps() != gei.getUsedWraps()); assertEquals(false, copy.isEvaluated()); assertEquals(1, copy.getAge()); assertEquals(true, gei.getPhenotype().getString().equals(copy.getPhenotype().getString())); assertNotSame(gei.getPhenotype(), copy.getPhenotype()); assertEquals(copy, copy.getFitness().getIndividual()); assertSame(copy, copy.getFitness().getIndividual()); assertEquals(false, copy.getGenotype().get(0) == gei.getMapper().getGenotype()); assertEquals(true, copy.getGenotype().get(0).toString().equals(copy.getMapper().getGenotype().toString())); assertEquals(gei.getPhenotype(), copy.getPhenotype()); assertEquals(true, copy.getMapper() instanceof GEGrammar); assertEquals(false, copy.getMapper() == gei.getMapper()); }