Interface Measurable<Q extends Quantity>
- All Superinterfaces:
Comparable<Measurable<Q>>
- All Known Implementing Classes:
Altitude
,Amount
,DecimalMeasure
,Height
,Measure
,Time
,VectorMeasure
This interface represents the measurable, countable, or comparable property or aspect of a thing.
Implementing instances are typically the result of a measurement:[code]
Measurable
Although measurable instances are for the most part scalar quantities;
more complex implementations (e.g. vectors, data set) are allowed as
long as an aggregate magnitude can be determined. For example:[code]
class Velocity3D implements Measurable extends Measure<double[], Q> {
public doubleValue(Unit
unit) { ... } // Returns median value.
...
} [/code]
-
Method Summary
Methods inherited from interface java.lang.Comparable
compareTo
-
Method Details
-
doubleValue
Returns the value of this measurable stated in the specified unit as adouble
. If the measurable has too great a magnitude to be represented as adouble
, it will be converted toDouble.NEGATIVE_INFINITY
orDouble.POSITIVE_INFINITY
as appropriate.- Parameters:
unit
- the unit in which this measurable value is stated.- Returns:
- the numeric value after conversion to type
double
.
-
longValue
Returns the estimated integral value of this measurable stated in the specified unit as along
.Note: This method differs from the
Number.longValue()
in the sense that the closest integer value is returned and an ArithmeticException is raised instead of a bit truncation in case of overflow (safety critical).- Parameters:
unit
- the unit in which the measurable value is stated.- Returns:
- the numeric value after conversion to type
long
. - Throws:
ArithmeticException
- if this quantity cannot be represented as along
number in the specified unit.
-