public abstract class NumberGene<N extends Number<N>,G extends NumberGene<N,G>> extends Number<G> implements Gene<N,G>, Mean<G>, XMLSerializable
| Modifier and Type | Field and Description |
|---|---|
protected N |
_max
The maximum value of this
NumberGene. |
protected N |
_min
The minimum value of this
NumberGene. |
protected N |
_value
The value of this
NumberGene. |
| Modifier | Constructor and Description |
|---|---|
protected |
NumberGene() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract N |
box(Number value)
Boxes a given Java number into the required number object.
|
int |
compareTo(G that)
Remind that this method is not consistent with the
equals(Object)
method. |
G |
copy() |
double |
doubleValue() |
boolean |
equals(Object obj) |
N |
getAllele()
Return the allele of this gene.
|
N |
getMax()
Return the allowed max value.
|
N |
getMin()
Return the allowed min value.
|
N |
getNumber()
Return the number value of this gene.
|
int |
hashCode() |
boolean |
isLargerThan(G that) |
boolean |
isValid()
Test whether this is a valid NumberGene and its value is within the
interval closed interval [min, max].
|
long |
longValue() |
abstract G |
newInstance(N value)
Create a new gene from the given
value. |
G |
newInstance(Number value)
Create a new NumberGene with the same limits and the given value.
|
G |
opposite() |
G |
plus(G that) |
protected void |
set(N value,
N min,
N max)
Set the
NumerGene. |
G |
times(G that) |
Text |
toText() |
byteValue, floatValue, intValue, isGreaterThan, isLessThan, minus, pow, shortValue, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitnewInstanceprotected transient N extends Number<N> _min
NumberGene. This field is marked
as transient and must serialized manually by sub classes.protected transient N extends Number<N> _max
NumberGene. This field is marked
as transient and must serialized manually by sub classes.protected NumberGene()
protected abstract N box(Number value)
value - the Java number to box.public abstract G newInstance(N value)
value.value - the value of the new gene.public G newInstance(Number value)
value - The value of the new NumberGene.NullPointerException - if the given value is null.protected void set(N value, N min, N max)
NumerGene.value - The value of the number gene.min - The allowed min value of the gene.max - The allows max value of the gene.NullPointerException - if one of the given number is null.public boolean isValid()
isValid in interface Verifiablepublic N getNumber()
public N getAllele()
Genepublic double doubleValue()
doubleValue in class Number<G extends NumberGene<N,G>>public long longValue()
public boolean isLargerThan(G that)
isLargerThan in class Number<G extends NumberGene<N,G>>public G plus(G that)
plus in interface GroupAdditive<G extends NumberGene<N,G>>public G opposite()
opposite in interface GroupAdditive<G extends NumberGene<N,G>>public int compareTo(G that)
equals(Object)
method. Since this method only compares the value and the
equals method also takes the min and max value
into account.
final NumberGene〈?, ?〉 ng1 = ...
final NumberGene〈?, ?〉 ng2 = ...
if (ng1.equals(ng2) {
// Holds for every ng1 and ng2.
assert(ng1.compareTo(ng2) == 0);
}
if (ng1.compareTo(ng2) == 0) {
// Doesn't hold for every ng1 and ng2.
assert(ng1.equals(ng2));
}compareTo in interface Comparable<G extends NumberGene<N,G>>compareTo in class Number<G extends NumberGene<N,G>>© 2007-2013 Franz Wilhelmstötter (2013-12-18 20:17)