T
- the type of number the amount value is expressed inU
- the type of unit that this amount quantifiespublic abstract class Amount<T extends Number & Comparable<T>,U extends Unit<U>> extends Object implements Comparable<Amount<T,U>>
of(...)
methods.Modifier and Type | Class and Description |
---|---|
static class |
Amount.TypeOverflowException
Thrown when a checked operation on an amount would overflow.
|
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_BUFFER_SIZE |
static int |
DEFAULT_SENDBUF_SIZE |
Modifier and Type | Method and Description |
---|---|
T |
as(U unit) |
T |
asChecked(U unit)
Throws TypeOverflowException if an overflow occurs during scaling.
|
int |
compareTo(Amount<T,U> other) |
boolean |
equals(Object obj) |
U |
getUnit() |
T |
getValue() |
int |
hashCode() |
static <U extends Unit<U>> |
of(double number,
U unit)
Creates an amount that uses a
double value. |
static <U extends Unit<U>> |
of(float number,
U unit)
Creates an amount that uses a
float value. |
static <U extends Unit<U>> |
of(int number,
U unit)
Creates an amount that uses an
int value. |
static <U extends Unit<U>> |
of(long number,
U unit)
Creates an amount that uses a
long value. |
protected abstract T |
scale(double multiplier) |
String |
toString() |
public static final int DEFAULT_BUFFER_SIZE
public static final int DEFAULT_SENDBUF_SIZE
public T getValue()
public U getUnit()
public T asChecked(U unit)
public int compareTo(Amount<T,U> other)
compareTo
in interface Comparable<Amount<T extends Number & Comparable<T>,U extends Unit<U>>>
protected abstract T scale(double multiplier)
public static <U extends Unit<U>> Amount<Double,U> of(double number, U unit)
double
value.U
- the type of unit that the returned amount quantifiesnumber
- the number of units the returned amount should quantifyunit
- the unit the returned amount is expressed in terms ofnumber
of unit
spublic static <U extends Unit<U>> Amount<Float,U> of(float number, U unit)
float
value.U
- the type of unit that the returned amount quantifiesnumber
- the number of units the returned amount should quantifyunit
- the unit the returned amount is expressed in terms ofnumber
of unit
spublic static <U extends Unit<U>> Amount<Long,U> of(long number, U unit)
long
value.U
- the type of unit that the returned amount quantifiesnumber
- the number of units the returned amount should quantifyunit
- the unit the returned amount is expressed in terms ofnumber
of unit
spublic static <U extends Unit<U>> Amount<Integer,U> of(int number, U unit)
int
value.U
- the type of unit that the returned amount quantifiesnumber
- the number of units the returned amount should quantifyunit
- the unit the returned amount is expressed in terms ofnumber
of unit
sCopyright © 2017 Perforce Software. All Rights Reserved.