public final class CharacterGene extends Object implements Gene<Character,CharacterGene>, Comparable<CharacterGene>, Serializable
This is a
value-based class; use of identity-sensitive operations (including
reference equality (==), identity hash code, or synchronization) on
instances of CharacterGene may have unpredictable results and should
be avoided.
| Modifier and Type | Field and Description |
|---|---|
static CharSeq |
DEFAULT_CHARACTERS
The default character set used by this gene.
|
| Modifier and Type | Method and Description |
|---|---|
char |
charValue()
Return the
char value of this character gene. |
int |
compareTo(CharacterGene that) |
boolean |
equals(Object obj) |
Character |
getAllele()
Return the allele of this gene.
|
CharSeq |
getValidCharacters()
Return a (unmodifiable) set of valid characters.
|
int |
hashCode() |
boolean |
isValid()
Check if this object is valid.
|
boolean |
isValidCharacter(Character character)
Test, if the given character is valid.
|
CharacterGene |
newInstance()
Return a new, random gene with the same type and with the same constraints
than this gene.
|
CharacterGene |
newInstance(Character character)
Create a new character gene from the given character.
|
static CharacterGene |
of()
Create a new random character gene, chosen from the
DEFAULT_CHARACTERS. |
static CharacterGene |
of(Character character)
Create a new character gene from the given character.
|
static CharacterGene |
of(char character,
CharSeq validCharacters)
Create a new CharacterGene from the give character.
|
static CharacterGene |
of(CharSeq validCharacters)
Create a new CharacterGene with a randomly chosen character from the
set of valid characters.
|
String |
toString() |
public static final CharSeq DEFAULT_CHARACTERS
public boolean isValid()
VerifiableisValid in interface Verifiablepublic Character getAllele()
GenegetAllele in interface Gene<Character,CharacterGene>public char charValue()
char value of this character gene.char value.public boolean isValidCharacter(Character character)
character - The character to test.public CharSeq getValidCharacters()
CharSeq of valid characters.public int compareTo(CharacterGene that)
compareTo in interface Comparable<CharacterGene>that - The other gene to compare.Character.compareTo(java.lang.Character)public CharacterGene newInstance()
Genegene.getClass() == gene.newInstance().getClass(). Implementations
of this method has to use the Random object which can
be fetched from the RandomRegistry.newInstance in interface Gene<Character,CharacterGene>newInstance in interface Factory<CharacterGene>public CharacterGene newInstance(Character character)
getValidCharacters(), an invalid gene will be
created.newInstance in interface Gene<Character,CharacterGene>character - the character value of the created gene.NullPointerException - if the given character is
null.public static CharacterGene of(CharSeq validCharacters)
validCharacters - the valid characters for this gene.NullPointerException - if the validCharacters are
null.public static CharacterGene of(Character character)
DEFAULT_CHARACTERS, an invalid gene will be
created.character - the character value of the created gene.NullPointerException - if the given character is
null.public static CharacterGene of()
DEFAULT_CHARACTERS.public static CharacterGene of(char character, CharSeq validCharacters)
character - The allele.validCharacters - the valid characters fo the new geneCharacterGene with the given parameterNullPointerException - if one of the arguments is null.IllegalArgumentException - if the validCharacters are empty.© 2007-2016 Franz Wilhelmstötter (2016-04-24 10:25)