/** * Create a new chromosome from the given {@code genes} array. The genes * array is copied, so changes to the given genes array doesn't effect the * genes of this chromosome. * * @since 4.0 * * @param genes the genes that form the chromosome. * @param lengthRange the allowed length range of the chromosome. * @throws NullPointerException if the given gene array is {@code null}. * @throws IllegalArgumentException if the length of the gene array is * smaller than one. */ protected CharacterChromosome( final ISeq<CharacterGene> genes, final IntRange lengthRange ) { super(genes, lengthRange); _validCharacters = genes.get(0).getValidCharacters(); }
/** * Return a {@link Writer} for {@link io.jenetics.CharacterChromosome} * objects. * * @return a chromosome writer */ public static Writer<io.jenetics.CharacterChromosome> writer() { return elem(ROOT_NAME, attr(LENGTH_NAME).map(io.jenetics.CharacterChromosome::length), elem(VALID_ALLELES_NAME, text().map(ch -> ch.getGene().getValidCharacters())), elem(ALLELES_NAME, text().map(io.jenetics.CharacterChromosome::toString)) ); }