Package io.jenetics

Class CharacterGene

    • Method Detail

      • 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.
      • charValue

        public char charValue()
        Return the char value of this character gene.
        Returns:
        the char value.
      • isValidCharacter

        public boolean isValidCharacter​(Character allele)
        Test, if the given character is valid.
        Parameters:
        allele - The character to test.
        Returns:
        true if the character is valid, false otherwise.
      • validChars

        public CharSeq validChars()
        Return a (unmodifiable) set of valid characters.
        Returns:
        the CharSeq of valid characters.
      • compareTo

        public int compareTo​(CharacterGene that)
        Specified by:
        compareTo in interface Comparable<CharacterGene>
        Parameters:
        that - The other gene to compare.
        Returns:
        the value 0 if the argument Character is equal to this Character; a value less than 0 if this Character is numerically less than the Character argument; and a value greater than 0 if this Character is numerically greater than the Character argument (unsigned comparison). Note that this is strictly a numerical comparison; it is not local-dependent.
        See Also:
        Character.compareTo(java.lang.Character)
      • of

        public static CharacterGene of​(CharSeq validCharacters)
        Create a new CharacterGene with a randomly chosen character from the set of valid characters.
        Parameters:
        validCharacters - the valid characters for this gene.
        Returns:
        a new valid, random gene,
        Throws:
        NullPointerException - if the validCharacters are null.
      • of

        public static CharacterGene of​(char allele)
        Create a new character gene from the given character. If the character is not within the DEFAULT_CHARACTERS, an invalid gene will be created.
        Parameters:
        allele - the character value of the created gene.
        Returns:
        a new character gene.
      • of

        public static CharacterGene of​(char allele,
                                       CharSeq validCharacters)
        Create a new CharacterGene from the give character.
        Parameters:
        allele - The allele.
        validCharacters - the valid characters fo the new gene
        Returns:
        a new CharacterGene with the given parameter
        Throws:
        NullPointerException - if one of the arguments is null.
        IllegalArgumentException - if the validCharacters are empty.