52
51
public abstract D fromDouble(double val);
55
* Returns the hash code for this NumberDistance, which is the hash code of
58
* @return the hash code of the value
61
public int hashCode() {
62
return getValue().hashCode();
66
* Compares this NumberDistance with the given NumberDistance wrt the
69
* <code>d1.compareTo(d2)</code> is the same as
70
* {@link Double#compare(double,double) Double.compare(d1.value.doubleValue(),
71
* d2.value.doubleValue())}. Subclasses may need to overwrite this method if
74
* @param other Other object
75
* @return a negative integer, zero, or a positive integer as the value of
76
* this NumberDistance is less than, equal to, or greater than the
77
* value of the specified NumberDistance.
80
public int compareTo(D other) {
81
return Double.compare(this.doubleValue(), other.doubleValue());
85
* Returns a string representation of this NumberDistance.
87
* @return the value of this NumberDistance.
90
public final String toString() {
91
return getValue().toString();
95
* Returns the value of this NumberDistance.
97
* @return the value of this NumberDistance
99
public abstract N getValue();
102
* Sets the value of this NumberDistance.
104
* @param value the value to be set
106
abstract void setValue(N value);
109
54
* Get the value as double.
111
56
* @return same result as getValue().doubleValue() but may be more efficient.
113
58
public abstract double doubleValue();
116
61
* Get the value as float.