|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectMeasure<Q>
Amount<Decimal,Money>
MoneyAmount
public class MoneyAmount
This class represents an amount of money specified in a given
Currency (convenience method).
| Field Summary |
|---|
| Fields inherited from class Amount |
|---|
TEXT_FORMAT, XML_FORMAT |
| Constructor Summary | |
|---|---|
MoneyAmount(Decimal value,
Currency unit)
Creates a money amount always on the heap independently from the current allocator context. |
|
| Method Summary | |
|---|---|
MoneyAmount |
copy()
Returns a copy of this amount (allocated in the current context). |
Amount<Decimal,?> |
divide(Amount<Decimal,?> that)
Returns this amount divided by the one specified. |
MoneyAmount |
divide(long n)
Returns this amount divided by the specified divisor. |
Currency |
getUnit()
Returns this amount unit. |
Decimal |
getValue()
Returns this amount numeric value. |
Amount<Decimal,?> |
inverse()
Returns the reciprocal of this amount. |
MoneyAmount |
minus(Amount<Decimal,?> that)
Returns the difference between this amount and the one specified. |
MoneyAmount |
opposite()
Returns the opposite of this amount. |
MoneyAmount |
plus(Amount<Decimal,?> that)
Returns the sum of this amount with the one specified. |
Amount<Decimal,?> |
pow(int exp)
Returns this amount raised at the specified exponent. |
Amount<Decimal,?> |
times(Amount<Decimal,?> that)
Returns the product of this amount with the one specified. |
MoneyAmount |
times(long n)
Returns this amount multiplied by the specified factor. |
String |
toStringLocale()
Overrides the default Measure.toStringLocale()
to show only the currency fraction
digits of the associated currency (e.g. |
static MoneyAmount |
valueOf(Amount<?,Money> amount)
Returns the money amount corresponding to the specified generic amount. |
static MoneyAmount |
valueOf(Decimal value,
Currency currency)
Returns the money amount corresponding to the specified decimal value and currency. |
static MoneyAmount |
valueOf(long value,
int cents,
Currency currency)
Returns the money amount corresponding to the specified value and cents. |
| Methods inherited from class Amount |
|---|
asFloat64, asType, decimalValue, doubleValue, to, to, toSI, toString, toText, valueOf, valueOf, valueOf |
| Methods inherited from class Measure |
|---|
compareTo, equals, equals, floatValue, hashCode, intValue, longValue, round |
| Methods inherited from class Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public MoneyAmount(Decimal value,
Currency unit)
allocator context.
To allow for custom object allocation policies, static factory methods
valueOf(...) are recommended.
value - the value stated in the specified currency.currency - the currency in which the value is stated.| Method Detail |
|---|
public static MoneyAmount valueOf(Decimal value,
Currency currency)
value - the value stated in the specified currency.currency - the currency in which the value is stated.
public static MoneyAmount valueOf(long value,
int cents,
Currency currency)
value - the integer value in the specified currency.cents - the cents value in the specified currency.currency - the currency in which the value and cents are stated.
public static MoneyAmount valueOf(Amount<?,Money> amount)
amount - the raw amount.
Currency.
ClassCastException - if the SI unit of the specified amount
is not a Currency.public String toStringLocale()
Measure.toStringLocale()
to show only the currency fraction
digits of the associated currency (e.g. rounding to closest cents).
toStringLocale in class Measure<Money>public Decimal getValue()
Amount
getValue in class Amount<Decimal,Money>public Currency getUnit()
Amount
getUnit in class Amount<Decimal,Money>public MoneyAmount opposite()
Amount
opposite in interface GroupAdditive<Amount<Decimal,?>>opposite in class Amount<Decimal,Money>-this.public MoneyAmount plus(Amount<Decimal,?> that)
Amount
plus in interface GroupAdditive<Amount<Decimal,?>>plus in class Amount<Decimal,Money>that - the amount to be added.
this + that.public MoneyAmount minus(Amount<Decimal,?> that)
Amount
minus in class Amount<Decimal,Money>that - the number to be subtracted.
this - that.public MoneyAmount times(long n)
Amount
times in class Amount<Decimal,Money>n - the factor multiplier.
this * n.public Amount<Decimal,?> times(Amount<Decimal,?> that)
Amount
times in interface GroupMultiplicative<Amount<Decimal,?>>times in interface Ring<Amount<Decimal,?>>times in class Amount<Decimal,Money>that - the number multiplier.
this ยท that.public Amount<Decimal,?> pow(int exp)
Amount
pow in class Amount<Decimal,Money>exp - the exponent.
thisexppublic Amount<Decimal,?> inverse()
Amount
inverse in interface GroupMultiplicative<Amount<Decimal,?>>inverse in class Amount<Decimal,Money>1 / this.public MoneyAmount divide(long n)
Amount
divide in class Amount<Decimal,Money>n - the divisor.
this / n.public Amount<Decimal,?> divide(Amount<Decimal,?> that)
Amount
divide in class Amount<Decimal,Money>that - the amount divisor.
this / that.public MoneyAmount copy()
Amountcontext).
copy in interface ValueTypecopy in class Amount<Decimal,Money>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||