com.antelmann.math
Class Measure<T extends Unit>
java.lang.Object
com.antelmann.math.Measure<T>
- All Implemented Interfaces:
- Measurable, Serializable, Comparable<Measure<T>>
public class Measure<T extends Unit>
- extends Object
- implements Measurable, Comparable<Measure<T>>
represents some immutable generic measure to serve as a basis for sub-classing;
this class itself provides type safety for the unit in use.
A measure is typed to its unit, so that a programmer can ensure that only a
measure of a certain type is used when setting a value.
- Since:
- 04.06.2009, 15:17:04
- Author:
- Holger Antelmann
- See Also:
Unit,
Serialized Form
Measure
public Measure(Number number,
T unit)
getAmount
public Number getAmount()
- Description copied from interface:
Measurable
- represents the quantity of this measurable entity
- Specified by:
getAmount in interface Measurable
getUnit
public final T getUnit()
- Description copied from interface:
Measurable
- represents the unit type of this measurable entity
- Specified by:
getUnit in interface Measurable
compareTo
public int compareTo(Measure<T> m)
- Specified by:
compareTo in interface Comparable<Measure<T extends Unit>>
toString
public String toString()
- Overrides:
toString in class Object
hashCode
public int hashCode()
- Overrides:
hashCode in class Object
equals
public boolean equals(Object obj)
- this implementation is unaware that 1000g is 'equal' to 1kg; that's the job of a subclass
- Overrides:
equals in class Object
(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads