public final class IntegerGene extends Object implements NumericGene<Integer,IntegerGene>, Mean<IntegerGene>, Comparable<IntegerGene>, Serializable
This is a
value-based class; use of identity-sensitive operations (including
reference equality (==
), identity hash code, or synchronization) on
instances of IntegerGene
may have unpredictable results and should
be avoided.
IntegerChromosome
,
Serialized FormModifier and Type | Method and Description |
---|---|
byte |
byteValue()
Returns the value of the specified gene as an byte.
|
int |
compareTo(IntegerGene other) |
double |
doubleValue()
Returns the value of the specified gene as an double.
|
boolean |
equals(Object obj) |
float |
floatValue()
Returns the value of the specified gene as an float.
|
Integer |
getAllele()
Return the allele of this gene.
|
Integer |
getMax()
Return the allowed max value.
|
Integer |
getMin()
Return the allowed min value.
|
int |
hashCode() |
int |
intValue()
Returns the value of the specified gene as an int.
|
boolean |
isValid()
Check if this object is valid.
|
long |
longValue()
Returns the value of the specified gene as an long.
|
IntegerGene |
mean(IntegerGene that)
Return the (usually arithmetic) mean value of
this and
that . |
IntegerGene |
newInstance()
Return a new, random gene with the same type and with the same constraints
than this gene.
|
IntegerGene |
newInstance(Integer number)
Create a new gene from the given
value and the current bounds. |
IntegerGene |
newInstance(Number number)
Create a new gene from the given
value and the current bounds. |
static IntegerGene |
of(int min,
int max)
Create a new random
IntegerGene . |
static IntegerGene |
of(int value,
int min,
int max)
Create a new random
IntegerGene with the given value and the
given range. |
static IntegerGene |
of(int value,
IntRange range)
Create a new random
IntegerGene with the given value and the
given range. |
static IntegerGene |
of(IntRange range)
Create a new random
IntegerGene . |
short |
shortValue()
Returns the value of the specified gene as an short.
|
String |
toString() |
public Integer getAllele()
Gene
getAllele
in interface Gene<Integer,IntegerGene>
public Integer getMin()
BoundedGene
getMin
in interface BoundedGene<Integer,IntegerGene>
public Integer getMax()
BoundedGene
getMax
in interface BoundedGene<Integer,IntegerGene>
public byte byteValue()
NumericGene
byteValue
in interface NumericGene<Integer,IntegerGene>
byte
.public short shortValue()
NumericGene
shortValue
in interface NumericGene<Integer,IntegerGene>
short
.public int intValue()
NumericGene
intValue
in interface NumericGene<Integer,IntegerGene>
int
.public long longValue()
NumericGene
longValue
in interface NumericGene<Integer,IntegerGene>
long
.public float floatValue()
NumericGene
floatValue
in interface NumericGene<Integer,IntegerGene>
float
.public double doubleValue()
NumericGene
doubleValue
in interface NumericGene<Integer,IntegerGene>
double
.public boolean isValid()
Verifiable
isValid
in interface BoundedGene<Integer,IntegerGene>
isValid
in interface Verifiable
public int compareTo(IntegerGene other)
compareTo
in interface BoundedGene<Integer,IntegerGene>
compareTo
in interface Comparable<IntegerGene>
public IntegerGene newInstance(Integer number)
BoundedGene
value
and the current bounds.newInstance
in interface BoundedGene<Integer,IntegerGene>
newInstance
in interface Gene<Integer,IntegerGene>
number
- the value of the new gene.public IntegerGene newInstance(Number number)
BoundedGene
value
and the current bounds.newInstance
in interface NumericGene<Integer,IntegerGene>
number
- the value of the new gene.public IntegerGene newInstance()
Gene
gene.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<Integer,IntegerGene>
newInstance
in interface Factory<IntegerGene>
public IntegerGene mean(IntegerGene that)
Mean
this
and
that
. For NumericGene
s the mean is the
arithmetic mean.mean
in interface Mean<IntegerGene>
that
- the second value for calculating the mean.this
and that
.public static IntegerGene of(int value, int min, int max)
IntegerGene
with the given value and the
given range. If the value
isn't within the interval [min, max],
no exception is thrown. In this case the method
isValid()
returns false
.value
- the value of the gene.min
- the minimal valid value of this gene (inclusively).max
- the maximal valid value of this gene (inclusively).IntegerGene
with the given value
public static IntegerGene of(int value, IntRange range)
IntegerGene
with the given value and the
given range. If the value
isn't within the interval [min, max],
no exception is thrown. In this case the method
isValid()
returns false
.value
- the value of the gene.range
- the integer range to useIntegerGene
with the give value
NullPointerException
- if the given range
is null
.public static IntegerGene of(int min, int max)
IntegerGene
. It is guaranteed that the value of
the IntegerGene
lies in the interval [min, max].min
- the minimal valid value of this gene (inclusively).max
- the maximal valid value of this gene (inclusively).IntegerGene
public static IntegerGene of(IntRange range)
IntegerGene
. It is guaranteed that the value of
the IntegerGene
lies in the interval [min, max].range
- the integer range to useIntegerGene
NullPointerException
- if the given range
is null
.© 2007-2018 Franz Wilhelmstötter (2018-10-28 17:23)