| 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 weight = Measure.valueOf(180.0, POUND);
[/code]
They can also be created from custom classes:[code]
class Delay implements Measurable {
private long nanoSeconds; // Implicit internal unit.
public double doubleValue(Unit unit) { ... }
public long longValue(Unit unit) { ... }
}
Thread.wait(new Delay(24, HOUR)); // Assuming Thread.wait(Measurable) method.
[/code]
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 {
private double x, y, z; // Meter per seconds.
public double doubleValue(Unit unit) { ... } // Returns vector norm.
...
}
class Sensors extends Measure {
public doubleValue(Unit unit) { ... } // Returns median value.
...
} [/code]
author: Jean-Marie Dautelle version: 4.1, June 8, 2007 |