Packages

  • package root
    Definition Classes
    root
  • package squants

    The Scala API for Quantities, Units of Measure and Dimensional Analysis

    Squants

    The Scala API for Quantities, Units of Measure and Dimensional Analysis

    Overview

    Squants is a framework of data types and a domain specific language (DSL) for representing Quantities, their Units of Measure, and their Dimensional relationships. The API supports typesafe dimensional analysis, improved domain models and more. All types are immutable and thread-safe.

    Typedefs and implicits for common usages

    Definition Classes
    root
    Version

    0.1

    Since

    0.1

  • package market

    Squants Market API

    Squants Market API

    Market Types are similar but not quite the same as other quantities in the library.

    The primary type, squants.market.Money, is derived from Quantity, and its Units of Measure are Currencies. However, because the conversion multipliers between units can not be predefined, many of the behaviors have been overridden and augmented to realize correct behavior.

    squants.market.Prices represent a Ratio between Money and some other Quantity. Prices can be created from ratios of Money and a Quantity

    val money: Money = USD(10)
    val length: Length = Meters(1)
    val price: Price[Length] = money / length

    Multiplying a Price * Quantity will yield Money amount that represents the cost of the quantity

    val cost: Money = price * Meters(3.8)

    and multiplying Price * Money will yield the corresponding Quantity amount

    val budget: Money = USD(250)
    val quote: Length = price * budget

    squants.market.CurrencyExchangeRates represent conversion rates between currencies. Use them to explicitly convert Money values in one currency to values in another.

    squants.market.MoneyContext provide the implicit context necessary to perform cross-currency operations on Money values with conversions automatically applied.

    Some binary math operations will work on Moneys of like Currency with no MoneyContext in scope. Attempts to perform these operations on Moneys of dissimilar currencies will throw an exception at runtime.

    Other operations, including direct conversions to other currencies, require a MoneyContext and will not compile without it. However, there is no compile time check to determine if the correct exchange rates will be available at runtime. Operation requiring conversion without the required rates available will throw a NoSuchExchangeRateException at runtime.

    The defaultMoneyContext uses the USD as the default and provides a list of ~20 common currencies, and NO exchange rates. If your application requires something different you should initialize your own implicit MoneyContext

    Definition Classes
    squants
    Since

    0.1

  • ARS
  • AUD
  • BRL
  • BTC
  • CAD
  • CHF
  • CLP
  • CNY
  • CZK
  • Currency
  • CurrencyExchangeRate
  • DKK
  • ETH
  • EUR
  • GBP
  • HKD
  • INR
  • JPY
  • KRW
  • LTC
  • MXN
  • MYR
  • Money
  • MoneyContext
  • MoneyConversions
  • NAD
  • NOK
  • NZD
  • NoSuchCurrencyException
  • NoSuchExchangeRateException
  • Price
  • RUB
  • SEK
  • USD
  • XAG
  • XAU
  • ZAR

case class Price[A <: Quantity[A]](money: squants.Money, quantity: A) extends Ratio[squants.Money, A] with Serializable with Product

Represents a price

A price is an squants.Ratio between a quantity of squants.market.Money and some other squants.Quantity

A

Quantity Type

money

Money

quantity

Quantity

Source
Price.scala
Since

0.1

Linear Supertypes
Product, Equals, Serializable, Ratio[squants.Money, A], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Price
  2. Product
  3. Equals
  4. Serializable
  5. Ratio
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new Price(money: squants.Money, quantity: A)

    money

    Money

    quantity

    Quantity

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. def *(that: A): squants.Money

    Returns the Cost (Money) for a quantity that of A

    Returns the Cost (Money) for a quantity that of A

    that

    Quantity

  4. def *(that: BigDecimal): Price[A]
  5. def *(that: Double): Price[A]
  6. def +(that: Price[A]): Price[A]
  7. def -(that: Price[A]): Price[A]
  8. def /(that: Price[A]): BigDecimal
  9. def /(that: BigDecimal): Price[A]
  10. def /(that: Double): Price[A]
  11. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  12. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  13. def base: squants.Money
    Definition Classes
    PriceRatio
  14. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  15. def convertToBase(q: A): squants.Money
    Definition Classes
    Ratio
  16. def convertToCounter(q: squants.Money): A
    Definition Classes
    Ratio
  17. def counter: A
    Definition Classes
    PriceRatio
  18. def divide(that: Price[A]): BigDecimal
  19. def divide(that: BigDecimal): Price[A]
  20. def divide(that: Double): Price[A]
  21. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  22. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  23. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  24. def in(currency: Currency)(implicit moneyContext: MoneyContext): squants.Price[A]
  25. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  26. def minus(that: Price[A]): Price[A]
  27. val money: squants.Money
  28. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  29. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  30. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  31. def plus(that: Price[A]): Price[A]
  32. def productElementNames: Iterator[String]
    Definition Classes
    Product
  33. val quantity: A
  34. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  35. def times(that: BigDecimal): Price[A]
  36. def times(that: Double): Price[A]
  37. def toString(currency: Currency, unit: UnitOfMeasure[A])(implicit moneyContext: MoneyContext): String
  38. def toString(unit: UnitOfMeasure[A]): String
  39. def toString(): String
    Definition Classes
    Price → AnyRef → Any
  40. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  41. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  42. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Deprecated Value Members

  1. def *(that: squants.Money): A

    Returns the Quantity that will cost that)

    Returns the Quantity that will cost that)

    that

    Money

    Annotations
    @deprecated
    Deprecated

    (Since version 0.6.3) Use money / price instead

Inherited from Product

Inherited from Equals

Inherited from Serializable

Inherited from Ratio[squants.Money, A]

Inherited from AnyRef

Inherited from Any

Ungrouped