Holger's
Java API

com.antelmann.math
Class Measure<T extends Unit>

java.lang.Object
  extended by 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

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.antelmann.math.Measurable
Measurable.Adapter
 
Constructor Summary
Measure(Number number, T unit)
           
 
Method Summary
 int compareTo(Measure<T> m)
           
 boolean equals(Object obj)
          this implementation is unaware that 1000g is 'equal' to 1kg; that's the job of a subclass
 Number getAmount()
          represents the quantity of this measurable entity
 T getUnit()
          represents the unit type of this measurable entity
 int hashCode()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Measure

public Measure(Number number,
               T unit)
Method Detail

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