org.broadleafcommerce.common.money
Class Money

java.lang.Object
  extended by org.broadleafcommerce.common.money.Money
All Implemented Interfaces:
Externalizable, Serializable, Cloneable, Comparable<Money>
Direct Known Subclasses:
NonModifiableMoney

public class Money
extends Object
implements Serializable, Cloneable, Comparable<Money>, Externalizable

See Also:
Serialized Form

Field Summary
static Money ZERO
           
 
Constructor Summary
Money()
           
Money(BigDecimal amount)
           
Money(BigDecimal amount, Currency currency)
           
Money(BigDecimal amount, Currency currency, int scale)
           
Money(BigDecimal amount, String currencyCode)
           
Money(double amount)
           
Money(double amount, Currency currency)
           
Money(double amount, String currencyCode)
           
Money(int amount)
           
Money(int amount, Currency currency)
           
Money(int amount, String currencyCode)
           
Money(long amount)
           
Money(long amount, Currency currency)
           
Money(long amount, String currencyCode)
           
Money(String amount)
           
Money(String amount, Currency currency)
           
Money(String amount, String currencyCode)
           
 
Method Summary
 Money abs()
           
static Money abs(Money money)
           
 Money add(Money other)
           
 Object clone()
           
 int compareTo(BigDecimal value)
           
 int compareTo(Money other)
           
static Currency defaultCurrency()
          Attempts to load a default currency by using the default locale.
 Money divide(BigDecimal divisor)
           
 Money divide(double amount)
           
 Money divide(int amount)
           
 double doubleValue()
           
 boolean equals(Object o)
           
 BigDecimal getAmount()
           
 Currency getCurrency()
           
 boolean greaterThan(BigDecimal value)
           
 boolean greaterThan(Money other)
           
 boolean greaterThanOrEqual(BigDecimal value)
           
 boolean greaterThanOrEqual(Money other)
           
 int hashCode()
           
 boolean isZero()
           
 boolean lessThan(BigDecimal value)
           
 boolean lessThan(Money other)
           
 boolean lessThanOrEqual(BigDecimal value)
           
 boolean lessThanOrEqual(Money other)
           
 Money max(Money other)
           
static Money max(Money left, Money right)
           
 Money min(Money other)
           
static Money min(Money left, Money right)
           
 Money multiply(BigDecimal multiplier)
           
 Money multiply(double amount)
           
 Money multiply(int amount)
           
 Money negate()
           
 void readExternal(ObjectInput in)
           
 String stringValue()
           
 Money subtract(Money other)
           
static BigDecimal toAmount(Money money)
           
static Currency toCurrency(Money money)
           
 String toString()
           
 void writeExternal(ObjectOutput out)
           
 Money zero()
           
static Money zero(Currency currency)
           
static Money zero(String currencyCode)
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO

public static final Money ZERO
Constructor Detail

Money

public Money()

Money

public Money(BigDecimal amount)

Money

public Money(double amount)

Money

public Money(int amount)

Money

public Money(long amount)

Money

public Money(String amount)

Money

public Money(BigDecimal amount,
             String currencyCode)

Money

public Money(double amount,
             Currency currency)

Money

public Money(double amount,
             String currencyCode)

Money

public Money(int amount,
             Currency currency)

Money

public Money(int amount,
             String currencyCode)

Money

public Money(long amount,
             Currency currency)

Money

public Money(long amount,
             String currencyCode)

Money

public Money(String amount,
             Currency currency)

Money

public Money(String amount,
             String currencyCode)

Money

public Money(BigDecimal amount,
             Currency currency)

Money

public Money(BigDecimal amount,
             Currency currency,
             int scale)
Method Detail

getAmount

public BigDecimal getAmount()

getCurrency

public Currency getCurrency()

add

public Money add(Money other)

subtract

public Money subtract(Money other)

multiply

public Money multiply(double amount)

multiply

public Money multiply(int amount)

multiply

public Money multiply(BigDecimal multiplier)

divide

public Money divide(double amount)

divide

public Money divide(int amount)

divide

public Money divide(BigDecimal divisor)

abs

public Money abs()

min

public Money min(Money other)

max

public Money max(Money other)

negate

public Money negate()

isZero

public boolean isZero()

zero

public Money zero()

lessThan

public boolean lessThan(Money other)

lessThan

public boolean lessThan(BigDecimal value)

lessThanOrEqual

public boolean lessThanOrEqual(Money other)

lessThanOrEqual

public boolean lessThanOrEqual(BigDecimal value)

greaterThan

public boolean greaterThan(Money other)

greaterThan

public boolean greaterThan(BigDecimal value)

greaterThanOrEqual

public boolean greaterThanOrEqual(Money other)

greaterThanOrEqual

public boolean greaterThanOrEqual(BigDecimal value)

compareTo

public int compareTo(Money other)
Specified by:
compareTo in interface Comparable<Money>

compareTo

public int compareTo(BigDecimal value)

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

clone

public Object clone()
Overrides:
clone in class Object

toString

public String toString()
Overrides:
toString in class Object

doubleValue

public double doubleValue()

stringValue

public String stringValue()

zero

public static Money zero(String currencyCode)

zero

public static Money zero(Currency currency)

abs

public static Money abs(Money money)

min

public static Money min(Money left,
                        Money right)

max

public static Money max(Money left,
                        Money right)

toAmount

public static BigDecimal toAmount(Money money)

toCurrency

public static Currency toCurrency(Money money)

defaultCurrency

public static Currency defaultCurrency()
Attempts to load a default currency by using the default locale. Currency.getInstance(Locale) uses the country component of the locale to resolve the currency. In some instances, the locale may not have a country component, in which case the default currency can be controlled with a system property.

Returns:
The default currency to use when none is specified

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException


Copyright © 2013. All Rights Reserved.