|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.codestreet.messageforge.RMoney
Class to represent a Money field. The motivation and implementation of this data type comes from the book Patterns of Enterprise Application Architecture by Martin Fowler.
Method Summary | |
RMoney |
add(RMoney another)
Addition operator. |
RMoney[] |
allocate(long[] ratios)
Allocate amount in specified ratios. |
int |
compareTo(java.lang.Object another)
Interface implementation. |
int |
compareTo(RMoney another)
Interface implementation. |
RMoney |
divide(java.math.BigDecimal amount)
Division operator. |
RMoney |
divide(java.math.BigDecimal amount,
int roundingMode)
Division operator. |
RMoney |
divide(double amount)
Division operator. |
RMoney |
divide(RMoney amount)
Division operator. |
boolean |
equals(java.lang.Object another)
Override. |
boolean |
equals(RMoney another)
Equals. |
java.math.BigDecimal |
getAmount()
Get amount. |
java.util.Currency |
getCurrency()
Get currency. |
int |
hashCode()
Override. |
long |
longValue()
Get amount as a long. |
RMoney |
multiply(java.math.BigDecimal amount)
Multiplication operator. |
RMoney |
multiply(double amount)
Multiplication operator. |
RMoney |
multiply(RMoney amount)
Multiplication operator. |
RMoney |
subtract(RMoney another)
Subtraction operator. |
static RMoney |
valueOf(double amount,
java.util.Currency currency)
Factory. |
static RMoney |
valueOf(long amount,
java.util.Currency currency)
Factory. |
static RMoney |
valueOfDollar(double amount)
Factory. |
static RMoney |
valueOfDollar(long amount)
Factory. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static RMoney valueOfDollar(long amount)
amount
- USD amount.
public static RMoney valueOfDollar(double amount)
amount
- USD amount.
public static RMoney valueOf(long amount, java.util.Currency currency)
amount
- Amount in specified currency.currency
- Currency.
public static RMoney valueOf(double amount, java.util.Currency currency)
amount
- Amount in specified currency.currency
- Currency.
public java.math.BigDecimal getAmount()
public long longValue()
public java.util.Currency getCurrency()
public boolean equals(java.lang.Object another)
public boolean equals(RMoney another)
public int hashCode()
public RMoney add(RMoney another)
another
- Argument.
public RMoney subtract(RMoney another)
another
- Argument.
public RMoney multiply(double amount)
amount
- Amount to multiple by.
public RMoney multiply(RMoney amount)
amount
- Amount to multiple by.
public RMoney multiply(java.math.BigDecimal amount)
amount
- Amount to multiple by.
public RMoney divide(double amount)
amount
- Amount to divide by.
public RMoney divide(java.math.BigDecimal amount)
amount
- Amount to divide by.
public RMoney divide(RMoney amount)
amount
- Amount to divide by.
public RMoney divide(java.math.BigDecimal amount, int roundingMode)
amount
- Amount to divide by.roundingMode
- Rounding mode. See BigDecimal for
details.
public int compareTo(java.lang.Object another)
compareTo
in interface java.lang.Comparable
another
- Argument.
public int compareTo(RMoney another)
another
- Argument.
public RMoney[] allocate(long[] ratios)
ratios
- Ratios. Sum of ratios must be greater than 0.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |