Package io.jenetics

Class EnumGene<A>

    • Method Detail

      • validAlleles

        public ISeq<AvalidAlleles()
        Return sequence of the valid alleles where this gene is a part of.
        Returns:
        the sequence of the valid alleles.
      • alleleIndex

        public int alleleIndex()
        Return the index of the allele this gene is representing.
        Returns:
        the index of the allele this gene is representing.
      • allele

        public A allele()
        Description copied from interface: Gene
        Return the allele of this gene.
        Specified by:
        allele in interface Gene<A,​EnumGene<A>>
        Returns:
        the allele of this gene.
      • isValid

        public 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.
      • newInstance

        public EnumGene<AnewInstance()
        Description copied from interface: Gene
        Return a new, random gene with the same type and with the same constraints than this gene. For all genes returned by this method holds gene.getClass() == gene.newInstance().getClass(). Implementations of this method has to use the Random object which can be fetched from the RandomRegistry.
        Specified by:
        newInstance in interface Factory<A>
        Specified by:
        newInstance in interface Gene<A,​EnumGene<A>>
        Returns:
        a new instance of type T
      • newInstance

        public EnumGene<AnewInstance​(A value)
        Create a new gene from the given value and the gene context.
        Specified by:
        newInstance in interface Gene<A,​EnumGene<A>>
        Parameters:
        value - the value of the new gene.
        Returns:
        a new gene with the given value.
        Since:
        1.6
      • of

        public static <A> EnumGene<A> of​(int alleleIndex,
                                         ISeq<? extends A> validAlleles)
        Create a new enum gene from the given valid genes and the chosen allele index.
        Type Parameters:
        A - the allele type
        Parameters:
        alleleIndex - the index of the allele for this gene.
        validAlleles - the sequence of valid alleles.
        Returns:
        a new EnumGene with the given with the allele validAlleles.get(alleleIndex)
        Throws:
        IllegalArgumentException - if the give valid alleles sequence is empty
        NullPointerException - if the valid alleles seq is null.
        Since:
        3.4
      • of

        public static <A> EnumGene<A> of​(ISeq<? extends A> validAlleles)
        Return a new enum gene with an allele randomly chosen from the given valid alleles.
        Type Parameters:
        A - the allele type
        Parameters:
        validAlleles - the sequence of valid alleles.
        Returns:
        a new EnumGene with an randomly chosen allele from the sequence of valid alleles
        Throws:
        IllegalArgumentException - if the give valid alleles sequence is empty
        NullPointerException - if the valid alleles seq is null.
      • of

        @SafeVarargs
        public static <A> EnumGene<A> of​(int alleleIndex,
                                         A... validAlleles)
        Create a new enum gene from the given valid genes and the chosen allele index.
        Type Parameters:
        A - the allele type
        Parameters:
        alleleIndex - the index of the allele for this gene.
        validAlleles - the array of valid alleles.
        Returns:
        a new EnumGene with the given with the allele validAlleles[alleleIndex]
        Throws:
        IllegalArgumentException - if the give valid alleles array is empty of the allele index is out of range.
      • of

        @SafeVarargs
        public static <A> EnumGene<A> of​(A... validAlleles)
        Return a new enum gene with an allele randomly chosen from the given valid alleles.
        Type Parameters:
        A - the allele type
        Parameters:
        validAlleles - the array of valid alleles.
        Returns:
        a new EnumGene with an randomly chosen allele from the sequence of valid alleles
        Throws:
        IllegalArgumentException - if the give valid alleles array is empty