T
- Used to enforce just-in-case subclass type checking for methods like lt(Unit)
so you can't compare one subclass with another subclass.public abstract class Unit<T extends Unit>
extends java.lang.Object
Constructor and Description |
---|
Unit() |
Modifier and Type | Method and Description |
---|---|
Unit<T> |
dividedBy(Unit<T> other)
Returns a new instance that is the result of doing
this / other . |
boolean |
equals(java.lang.Object object)
Returns
== using getRawValue() . |
protected abstract double |
getRawValue()
Subclasses must implement this to return their raw
double value. |
boolean |
gt(double otherUnit)
"greater than" comparison.
|
boolean |
gt(Unit<T> otherUnit)
"greater than" comparison.
|
boolean |
gte(double otherUnit)
"greater than or equal" comparison.
|
boolean |
gte(Unit<T> otherUnit)
"greater than or equal" comparison.
|
int |
hashCode()
|
boolean |
lt(double otherUnit)
"less than" comparison.
|
boolean |
lt(Unit<T> otherUnit)
"less than" comparison.
|
boolean |
lte(double otherUnit)
"less than or equal" comparison.
|
boolean |
lte(Unit<T> otherUnit)
"less than or equal" comparison.
|
Unit<T> |
minus(Unit<T> other)
Returns a new instance that is the result of doing
this - other . |
protected abstract Unit<T> |
newInstance(double rawValue)
Subclasses must override this so that arithmetic "operators" can create new instances.
|
Unit<T> |
plus(Unit<T> other)
Returns a new instance that is the result of doing
this + other . |
Unit<T> |
times(Unit<T> other)
Returns a new instance that is the result of doing
this * other . |
public boolean lt(double otherUnit)
public boolean lte(double otherUnit)
public boolean gt(double otherUnit)
public boolean gte(double otherUnit)
public Unit<T> minus(Unit<T> other)
this - other
.public Unit<T> plus(Unit<T> other)
this + other
.public Unit<T> times(Unit<T> other)
this * other
.public Unit<T> dividedBy(Unit<T> other)
this / other
.public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object object)
==
using getRawValue()
.equals
in class java.lang.Object
protected abstract double getRawValue()
double
value.