|
||||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Interface Summary | |
---|---|
Measurable<Q extends Quantity> | This interface represents the measurable, countable, or comparable property or aspect of a thing. |
Class Summary | |
---|---|
Measure<V,Q extends Quantity> | This class represents the result of a measurement stated in a known unit. |
Provides strongly typed measurements to enforce compile-time check of parameters consistency and avoid interface errors.
Let's take the following example:[code]
class Person {
void setWeight(double weight);
}[/code]
Should the weight be in pound, kilogram ??
Using measures there is no room for error:[code]
class Person {
void setWeight(Measurable
Users may create their own Measurable
implementation:[code]
public class Period implements Measurable
Users may also combine a definite amount (scalar, vector, collection, etc.)
to a unit and make it a Measure
(and
a Measurable
instance). For example:
[code]
// Scalar measurement (numerical).
person.setWeight(Measure.valueOf(180.0, POUND)); // Measure extends Measure
extends Measure
unit) { ... }
public Estimate
plus(Estimate
that) {...}
public Estimate> times(Estimate> that) {...}
... // doubleValue(Unit) returns estimated value.
}
[/code]
|
||||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |