com.elasticpath.domain.misc
Interface Money

All Superinterfaces:
java.lang.Comparable, EpDomain, java.io.Serializable, Transient
All Known Implementing Classes:
MoneyImpl

public interface Money
extends Transient, java.lang.Comparable

Represents an amount of money in a particular currency.


Method Summary
 Money add(Money otherMoney)
          Returns a new Money object representing the sum of this object and otherMoney's values.
 java.lang.String displaySalePercentage(Money salePrice, java.util.Locale locale)
          Creates a string to display the percentage savings at the specified sale price.
 java.lang.String displaySaleSavings(Money salePrice)
          Creates a string to display the amount saved at the specified sale price.
 java.math.BigDecimal getAmount()
          Get the amount of money as a BigDecimal.
 java.util.Currency getCurrency()
          Get the Currency of the money.
 java.lang.String getMoneyValueAndSymbol()
          Prints the symbol of the selected currency along with the value.
 boolean greaterThan(Money otherMoney)
          Returns true if this money object is greater than the specified other money object.
 boolean lessThan(Money otherMoney)
          Returns true if this money object is less than the specified other money object.
 Money multiply(java.math.BigDecimal multiplier)
          Return a new Money object whose value is this money object's value times the specified multiplier.
 Money multiply(int multiplier)
          Return a new Money object whose value is this money object's value times the specified multiplier.
 void setCurrency(java.util.Currency currency)
          Set the Currency of the money.
 void setValue(java.math.BigDecimal amount, java.util.Currency currency)
          Set the value that this object represents.
 void setValue(float amount, java.util.Currency currency)
          Set the value that this object represents.
 Money subtract(Money otherMoney)
          Returns a new Money object representing the the amount of this object less the amount of the otherMoney object.
 
Methods inherited from interface com.elasticpath.domain.EpDomain
getElasticPath, setElasticPath
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

add

Money add(Money otherMoney)
Returns a new Money object representing the sum of this object and otherMoney's values.

Parameters:
otherMoney - the Money object whose value is to be added to this object
Returns:
the new Money object representing the sum.

displaySalePercentage

java.lang.String displaySalePercentage(Money salePrice,
                                       java.util.Locale locale)
Creates a string to display the percentage savings at the specified sale price.

Parameters:
salePrice - the sale price
locale - the user's locale
Returns:
a string for displaying the percentage savings

displaySaleSavings

java.lang.String displaySaleSavings(Money salePrice)
Creates a string to display the amount saved at the specified sale price.

Parameters:
salePrice - the sale price
Returns:
a string for displaying the amount saved at the given sale price

getAmount

java.math.BigDecimal getAmount()
Get the amount of money as a BigDecimal.

Returns:
the BigDecimal amount

getCurrency

java.util.Currency getCurrency()
Get the Currency of the money.

Returns:
the Currency

getMoneyValueAndSymbol

java.lang.String getMoneyValueAndSymbol()
Prints the symbol of the selected currency along with the value.

Returns:
a string/html representation of the money value in the specified locale

greaterThan

boolean greaterThan(Money otherMoney)
Returns true if this money object is greater than the specified other money object.

Parameters:
otherMoney - the other money object
Returns:
true if this object is greater

lessThan

boolean lessThan(Money otherMoney)
Returns true if this money object is less than the specified other money object.

Parameters:
otherMoney - the other money object
Returns:
true if this object is less

multiply

Money multiply(java.math.BigDecimal multiplier)
Return a new Money object whose value is this money object's value times the specified multiplier.

Parameters:
multiplier - the amount to multiply by
Returns:
a Money object representing the result

multiply

Money multiply(int multiplier)
Return a new Money object whose value is this money object's value times the specified multiplier.

Parameters:
multiplier - the amount to multiply by
Returns:
a Money object representing the result

setCurrency

void setCurrency(java.util.Currency currency)
Set the Currency of the money.

Parameters:
currency - the Currency

setValue

void setValue(java.math.BigDecimal amount,
              java.util.Currency currency)
Set the value that this object represents.

Parameters:
amount - the amount of money as a BigDecimal
currency - the money's currency

setValue

void setValue(float amount,
              java.util.Currency currency)
Set the value that this object represents.

Parameters:
amount - the amount of money as a float
currency - the money's currency

subtract

Money subtract(Money otherMoney)
Returns a new Money object representing the the amount of this object less the amount of the otherMoney object.

Parameters:
otherMoney - the Money object whose value is to be subtracted from this object
Returns:
the new Money object representing this value less the other object's value.