Package io.jenetics

Interface Chromosome<G extends Gene<?,​G>>

    • Method Detail

      • gene

        default G gene()
        Return the first gene of this chromosome. Each chromosome must contain at least one gene.
        Returns:
        the first gene of this chromosome.
        Since:
        5.2
      • isValid

        default boolean isValid()
        Description copied from interface: Verifiable
        Check if this object is valid.
        Specified by:
        isValid in interface Verifiable
        Returns:
        true if this object is valid, false otherwise.
      • as

        default <C extends Chromosome<G>> C as​(Class<C> type)
        Casts this Chromosome to an instance of type C. This is a convenient method for an ordinary cast and allows seamless method-chaining. Instead of
        final Genotype<BitGene> gt = ... final int count = ((BitChromosome)gt.chromosome()).bitCount()
        you can write
        final Genotype<BitGene> gt = ... final int count = gt.chromosome() .as(BitChromosome.class) .bitCount()
        This may lead to a more elegant programming style in some cases.
        Type Parameters:
        C - the target chromosome type
        Parameters:
        type - the target type class
        Returns:
        this chromosome casted as C
        Throws:
        NullPointerException - if the target type class is null
        ClassCastException - if this chromosome can't be casted to a chromosome of type C
        Since:
        3.7