com.pmease.quickbuild.plugin.report.engine.util.quantity
Class Amount<T extends java.lang.Number & java.lang.Comparable<T>,U extends Unit<U>>

java.lang.Object
  extended by com.pmease.quickbuild.plugin.report.engine.util.quantity.Amount<T,U>
Type Parameters:
T - the type of number the amount value is expressed in
U - the type of unit that this amount quantifies
All Implemented Interfaces:
java.lang.Comparable<Amount<T,U>>

public abstract class Amount<T extends java.lang.Number & java.lang.Comparable<T>,U extends Unit<U>>
extends java.lang.Object
implements java.lang.Comparable<Amount<T,U>>

Represents a value in a unit system and facilitates unambiguous communication of amounts. Instances are created via static factory of(...) methods.


Method Summary
 T as(U unit)
           
 int compareTo(Amount<T,U> other)
           
 boolean equals(java.lang.Object obj)
           
 U getUnit()
           
 T getValue()
           
 int hashCode()
           
static
<U extends Unit<U>>
Amount<java.lang.Double,U>
of(double number, U unit)
          Creates an amount that uses a double value.
static
<U extends Unit<U>>
Amount<java.lang.Float,U>
of(float number, U unit)
          Creates an amount that uses a float value.
static
<U extends Unit<U>>
Amount<java.lang.Integer,U>
of(int number, U unit)
          Creates an amount that uses an int value.
static
<U extends Unit<U>>
Amount<java.lang.Long,U>
of(long number, U unit)
          Creates an amount that uses a long value.
protected abstract  T scale(double multiplier)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getValue

public T getValue()

getUnit

public U getUnit()

as

public T as(U unit)

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

compareTo

public int compareTo(Amount<T,U> other)
Specified by:
compareTo in interface java.lang.Comparable<Amount<T extends java.lang.Number & java.lang.Comparable<T>,U extends Unit<U>>>

scale

protected abstract T scale(double multiplier)

of

public static <U extends Unit<U>> Amount<java.lang.Double,U> of(double number,
                                                                U unit)
Creates an amount that uses a double value.

Type Parameters:
U - the type of unit that the returned amount quantifies
Parameters:
number - the number of units the returned amount should quantify
unit - the unit the returned amount is expressed in terms of
Returns:
an amount quantifying the given number of units

of

public static <U extends Unit<U>> Amount<java.lang.Float,U> of(float number,
                                                               U unit)
Creates an amount that uses a float value.

Type Parameters:
U - the type of unit that the returned amount quantifies
Parameters:
number - the number of units the returned amount should quantify
unit - the unit the returned amount is expressed in terms of
Returns:
an amount quantifying the given number of units

of

public static <U extends Unit<U>> Amount<java.lang.Long,U> of(long number,
                                                              U unit)
Creates an amount that uses a long value.

Type Parameters:
U - the type of unit that the returned amount quantifies
Parameters:
number - the number of units the returned amount should quantify
unit - the unit the returned amount is expressed in terms of
Returns:
an amount quantifying the given number of units

of

public static <U extends Unit<U>> Amount<java.lang.Integer,U> of(int number,
                                                                 U unit)
Creates an amount that uses an int value.

Type Parameters:
U - the type of unit that the returned amount quantifies
Parameters:
number - the number of units the returned amount should quantify
unit - the unit the returned amount is expressed in terms of
Returns:
an amount quantifying the given number of units


Copyright © 2005-2010 PMEase Inc. All Rights Reserved.