squants.market

MoneyContext

case class MoneyContext(defaultCurrency: Currency, currencies: Set[Currency], rates: Seq[CurrencyExchangeRate], allowIndirectConversions: Boolean = true) extends Product with Serializable

MoneyContext

Provides a context for Money specific operations.

When provided as an implicit parameter, the defaultCurrency will be used by the Money factory when no other currency is provided.

Provides for cross-currency conversions.

Will act as an implicit parameter to cross currency operations to allow for easy conversions

defaultCurrency

Currency used when none is supplied to the Money factory

rates

Collection of Exchange Rates used for currency conversions

Source
MoneyContext.scala
Since

0.1

Linear Supertypes
Serializable, Serializable, Product, Equals, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. MoneyContext
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. AnyRef
  7. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new MoneyContext(defaultCurrency: Currency, currencies: Set[Currency], rates: Seq[CurrencyExchangeRate], allowIndirectConversions: Boolean = true)

    defaultCurrency

    Currency used when none is supplied to the Money factory

    rates

    Collection of Exchange Rates used for currency conversions

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. def add(moneyA: Money, moneyB: Money): Money

    Adds two money values that may or may not be in the same currency.

    Adds two money values that may or may not be in the same currency.

    The result will be in the same currency as the first parameter.

    moneyA

    Money A

    moneyB

    Money B

    returns
    Exceptions thrown
    NoSuchExchangeRateException

    when no exchange rate is available

  7. val allowIndirectConversions: Boolean

  8. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  9. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  10. def compare(moneyA: Money, moneyB: Money): Int

    Performs a standard compare on two money values that may or may not be in the same currency

    Performs a standard compare on two money values that may or may not be in the same currency

    moneyA

    Money A

    moneyB

    Money B

    returns
    Exceptions thrown
    NoSuchExchangeRateException

    when no exchange rate is available

  11. def convert(money: Money, currency: Currency): Money

    Converts a Money value to the specified currency.

    Converts a Money value to the specified currency.

    The conversion first attempts to use an existing exchange rate for the two currencies in question. If no direct exchange works, a cross rate (limited to 1 hop) will be calculated and used. If no cross rate can be calculated a NoSuchElementException is thrown

    money

    Money to be converted

    currency

    Currency to be converted to

    returns
    Exceptions thrown
    NoSuchExchangeRateException

    when no exchange rate is available

  12. val currencies: Set[Currency]

  13. val defaultCurrency: Currency

    Currency used when none is supplied to the Money factory

  14. def directRateFor(curA: Currency, curB: Currency): Option[CurrencyExchangeRate]

    Returns an Option on an exchange rate if a direct rate exists, otherwise None

    Returns an Option on an exchange rate if a direct rate exists, otherwise None

    curA

    Currency A

    curB

    Currency B

    returns

  15. def divide(moneyA: Money, moneyB: Money): BigDecimal

    Divides two money value that may or may not be in the same currency after converting the second to the first

    Divides two money value that may or may not be in the same currency after converting the second to the first

    moneyA

    Money A

    moneyB

    Money B

    returns

  16. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  17. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  18. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  19. def indirectRateFor(curA: Currency, curB: Currency): Option[CurrencyExchangeRate]

    Return an Option on an exchange rate.

    Return an Option on an exchange rate. If a direct rate exists an Option on that will be returned. Otherwise, if a cross rate can be determined (1 hop limit), it will be created and returned in an Option. Otherwise, None will be returned

    curA

    Currency A

    curB

    Currency B

    returns

  20. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  21. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  22. final def notify(): Unit

    Definition Classes
    AnyRef
  23. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  24. val rates: Seq[CurrencyExchangeRate]

    Collection of Exchange Rates used for currency conversions

  25. def subtract(moneyA: Money, moneyB: Money): Money

    Subtracts two money values that may or may not be in the same currency

    Subtracts two money values that may or may not be in the same currency

    The result will be in the same currency as the first parameter.

    moneyA

    Money A

    moneyB

    Money B

    returns
    Exceptions thrown
    NoSuchExchangeRateException

    when no exchange rate is available

  26. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  27. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  28. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  30. def withExchangeRates(rates: List[CurrencyExchangeRate]): MoneyContext

    Create a copy of this context with a new list of rates

    Create a copy of this context with a new list of rates

    rates

    List[CurrencyExchangeRate]

    returns

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped