public final class LongGene extends Object implements NumericGene<Long,LongGene>, Mean<LongGene>, Comparable<LongGene>, Serializable
This is a
value-based class; use of identity-sensitive operations (including
reference equality (==
), identity hash code, or synchronization) on
instances of LongGene
may have unpredictable results and should
be avoided.
LongChromosome
,
Serialized FormModifier and Type | Method and Description |
---|---|
byte |
byteValue()
Returns the value of the specified gene as an byte.
|
int |
compareTo(LongGene 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.
|
Long |
getAllele()
Return the allele of this gene.
|
Long |
getMax()
Return the allowed max value.
|
Long |
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.
|
LongGene |
mean(LongGene that)
Return the (usually arithmetic) mean value of
this and
that . |
LongGene |
newInstance()
Return a new, random gene with the same type and with the same constraints
than this gene.
|
LongGene |
newInstance(long value)
Create a new gene from the given
value and the gene context. |
LongGene |
newInstance(Long number)
Create a new gene from the given
value and the current bounds. |
LongGene |
newInstance(Number number)
Create a new gene from the given
value and the current bounds. |
static LongGene |
of(long min,
long max)
Create a new random
LongGene . |
static LongGene |
of(long value,
long min,
long max)
Create a new random
LongGene with the given value and the
given range. |
static LongGene |
of(long value,
LongRange range)
Create a new random
LongGene with the given value and the
given range. |
static LongGene |
of(LongRange range)
Create a new random
LongGene . |
LongRange |
range()
Return the range of
this gene. |
short |
shortValue()
Returns the value of the specified gene as an short.
|
String |
toString() |
public Long getAllele()
Gene
public Long getMin()
BoundedGene
getMin
in interface BoundedGene<Long,LongGene>
public Long getMax()
BoundedGene
getMax
in interface BoundedGene<Long,LongGene>
public LongRange range()
this
gene.this
genepublic byte byteValue()
NumericGene
byteValue
in interface NumericGene<Long,LongGene>
byte
.public short shortValue()
NumericGene
shortValue
in interface NumericGene<Long,LongGene>
short
.public int intValue()
NumericGene
intValue
in interface NumericGene<Long,LongGene>
int
.public long longValue()
NumericGene
longValue
in interface NumericGene<Long,LongGene>
long
.public float floatValue()
NumericGene
floatValue
in interface NumericGene<Long,LongGene>
float
.public double doubleValue()
NumericGene
doubleValue
in interface NumericGene<Long,LongGene>
double
.public boolean isValid()
Verifiable
isValid
in interface BoundedGene<Long,LongGene>
isValid
in interface Verifiable
public int compareTo(LongGene other)
compareTo
in interface BoundedGene<Long,LongGene>
compareTo
in interface Comparable<LongGene>
public LongGene mean(LongGene that)
Mean
this
and
that
. For NumericGene
s the mean is the
arithmetic mean.public LongGene newInstance(long value)
value
and the gene context.value
- the value of the new gene.public LongGene newInstance(Long number)
BoundedGene
value
and the current bounds.newInstance
in interface BoundedGene<Long,LongGene>
newInstance
in interface Gene<Long,LongGene>
number
- the value of the new gene.public LongGene newInstance(Number number)
BoundedGene
value
and the current bounds.newInstance
in interface NumericGene<Long,LongGene>
number
- the value of the new gene.public LongGene 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<Long,LongGene>
newInstance
in interface Factory<LongGene>
public static LongGene of(long value, long min, long max)
LongGene
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).LongGene
with the given parameters.public static LongGene of(long value, LongRange range)
LongGene
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 long range to useLongGene
NullPointerException
- if the given range
is null
.public static LongGene of(long min, long max)
LongGene
. It is guaranteed that the value of
the LongGene
lies in the interval [min, max].min
- the minimal valid value of this gene (inclusively).max
- the maximal valid value of this gene (inclusively).LongGene
with the given parameters.public static LongGene of(LongRange range)
LongGene
. It is guaranteed that the value of
the LongGene
lies in the interval [min, max].range
- the long range to useLongGene
NullPointerException
- if the given range
is null
.© 2007-2019 Franz Wilhelmstötter (2019-11-18 20:30)