/** * Verifies the state of the chromosome. Especially takes care of the given constraint checker. * * @param a_constraintChecker the constraint checker to verify * @throws InvalidConfigurationException * @author Klaus Meffert * @since 2.5 */ protected void verify(IGeneConstraintChecker a_constraintChecker) throws InvalidConfigurationException { if (a_constraintChecker != null && getGenes() != null) { int len = getGenes().length; for (int i = 0; i < len; i++) { Gene gene = getGene(i); if (!a_constraintChecker.verify(gene, null, this, i)) { throw new InvalidConfigurationException( "The gene type " + gene.getClass().getName() + " is not allowed to be used in the chromosome due to the" + " constraint checker used."); } } } }
/** * @param a_gene Gene * @param a_xmlDocument Document * @return Element * @author Klaus Meffert * @since 2.0 */ private static Element representAlleleAsElement(final Gene a_gene, final Document a_xmlDocument) { Element alleleElement = a_xmlDocument.createElement(ALLELE_TAG); alleleElement.setAttribute("class", a_gene.getClass().getName()); alleleElement.setAttribute("value", a_gene.getPersistentRepresentation()); return alleleElement; }