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 electro

    Definition Classes
    squants
    Since

    0.1

  • package energy

    Definition Classes
    squants
    Since

    0.1

  • package experimental
    Definition Classes
    squants
  • package information
    Definition Classes
    squants
  • 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

  • package mass

    Definition Classes
    squants
    Since

    0.1

  • package motion

    Definition Classes
    squants
    Since

    0.1

  • package photo

    Definition Classes
    squants
    Since

    0.1

  • package radio

    Definition Classes
    squants
    Since

    0.1

  • package space

    Definition Classes
    squants
    Since

    0.1

  • package thermal

    Definition Classes
    squants
    Since

    0.1

  • package time

    Definition Classes
    squants
    Since

    0.1

  • AbstractQuantityNumeric
  • BaseDimension
  • BinarySystem
  • Dimension
  • Dimensionless
  • DimensionlessConversions
  • DimensionlessUnit
  • DoubleVector
  • Dozen
  • Each
  • Gross
  • LikeRatio
  • MetricSystem
  • Percent
  • Platform
  • PrimaryUnit
  • Quantity
  • QuantityParseException
  • QuantityRange
  • QuantityVector
  • Ratio
  • SVector
  • Score
  • SiBaseUnit
  • SiUnit
  • SquantifiedBigDecimal
  • SquantifiedDouble
  • SquantifiedInt
  • SquantifiedLong
  • UnitConverter
  • UnitOfMeasure
c

squants

AbstractQuantityNumeric

abstract class AbstractQuantityNumeric[A <: Quantity[A]] extends Numeric[A]

Base class for creating objects to manage quantities as Numeric.

One limitation is the times operation which is not supported by every quantity type

A

Quantity type

Source
AbstractQuantityNumeric.scala
Linear Supertypes
Numeric[A], Ordering[A], PartialOrdering[A], Equiv[A], Serializable, Serializable, Comparator[A], AnyRef, Any
Known Subclasses
DimensionlessNumeric, AreaElectricChargeDensityNumeric, CapacitanceNumeric, ConductivityNumeric, ElectricalChargeNumeric, ElectricChargeDensityNumeric, ElectricChargeMassRatioNumeric, ElectricCurrentNumeric, ElectricCurrentDensityNumeric, ElectricFieldStrengthNumeric, ElectricPotentialNumeric, ElectricalConductanceNumeric, ElectricalResistanceNumeric, InductanceNumeric, LinearElectricChargeDensityNumeric, MagneticFieldStrengthNumeric, MagneticFluxNumeric, MagneticFluxDensistyNumeric, PermeabilityNumeric, PermittivityNumeric, ResistivityNumeric, EnergyNumeric, EnergyDensityNumeric, MolarEnergyNumeric, PowerNumeric, PowerDensityNumeric, PowerRampNumeric, SpecificEnergyNumeric, DataRateNumeric, InformationNumeric, AreaDensityNumeric, ChemicalAmountNumeric, DensityNumeric, MassNumeric, MomentOfInertiaNumeric, AccelerationNumeric, AngularAccelerationNumeric, AngularVelocityNumeric, ForceNumeric, JerkNumeric, MassFlowNumeric, MomentumNumeric, PressureChangeNumeric, PressureNumeric, TorqueNumeric, VelocityNumeric, VolumeFlowNumeric, YankNumeric, IlluminanceNumeric, LuminanceNumeric, LuminousEnergyNumeric, LuminousExposureNumeric, LuminousFluxNumeric, LuminousIntensityNumeric, ActivityNumeric, AreaTimeNumeric, DoseNumeric, IrradianceNumeric, ParticleFluxNumeric, RadianceNumeric, RadiantIntensityNumeric, SpectralIntensityNumeric, SpectralIrradianceNumeric, SpectralPowerNumeric, AngleNumeric, AreaNumeric, LengthNumeric, SolidAngleNumeric, VolumeNumeric, ThermalCapacityNumeric, FrequencyNumeric, TimeNumeric
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. AbstractQuantityNumeric
  2. Numeric
  3. Ordering
  4. PartialOrdering
  5. Equiv
  6. Serializable
  7. Serializable
  8. Comparator
  9. AnyRef
  10. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new AbstractQuantityNumeric(unit: UnitOfMeasure[A] with PrimaryUnit)

Type Members

  1. class Ops extends AnyRef
    Definition Classes
    Numeric

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def abs(x: A): A
    Definition Classes
    Numeric
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  7. def compare(x: A, y: A): Int
    Definition Classes
    AbstractQuantityNumeric → Ordering → Comparator
  8. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  9. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  10. def equiv(x: A, y: A): Boolean
    Definition Classes
    Ordering → PartialOrdering → Equiv
  11. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. def fromInt(x: Int): A
    Definition Classes
    AbstractQuantityNumeric → Numeric
  13. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  14. def gt(x: A, y: A): Boolean
    Definition Classes
    Ordering → PartialOrdering
  15. def gteq(x: A, y: A): Boolean
    Definition Classes
    Ordering → PartialOrdering
  16. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  17. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  18. def lt(x: A, y: A): Boolean
    Definition Classes
    Ordering → PartialOrdering
  19. def lteq(x: A, y: A): Boolean
    Definition Classes
    Ordering → PartialOrdering
  20. def max(x: A, y: A): A
    Definition Classes
    Ordering
  21. def min(x: A, y: A): A
    Definition Classes
    Ordering
  22. def minus(x: A, y: A): A
    Definition Classes
    AbstractQuantityNumeric → Numeric
  23. implicit def mkNumericOps(lhs: A): Ops
    Definition Classes
    Numeric
  24. implicit def mkOrderingOps(lhs: A): AbstractQuantityNumeric.Ops
    Definition Classes
    Ordering
  25. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  26. def negate(x: A): A
    Definition Classes
    AbstractQuantityNumeric → Numeric
  27. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  28. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  29. def on[U](f: (U) ⇒ A): Ordering[U]
    Definition Classes
    Ordering
  30. def one: A
    Definition Classes
    Numeric
  31. def parseString(str: String): Option[A]
  32. def plus(x: A, y: A): A
    Definition Classes
    AbstractQuantityNumeric → Numeric
  33. def reverse: Ordering[A]
    Definition Classes
    Ordering → PartialOrdering
  34. def reversed(): Comparator[A]
    Definition Classes
    Comparator
  35. def signum(x: A): Int
    Definition Classes
    Numeric
  36. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  37. def thenComparing[U <: Comparable[_ >: U]](arg0: Function[_ >: A, _ <: U]): Comparator[A]
    Definition Classes
    Comparator
  38. def thenComparing[U](arg0: Function[_ >: A, _ <: U], arg1: Comparator[_ >: U]): Comparator[A]
    Definition Classes
    Comparator
  39. def thenComparing(arg0: Comparator[_ >: A]): Comparator[A]
    Definition Classes
    Comparator
  40. def thenComparingDouble(arg0: ToDoubleFunction[_ >: A]): Comparator[A]
    Definition Classes
    Comparator
  41. def thenComparingInt(arg0: ToIntFunction[_ >: A]): Comparator[A]
    Definition Classes
    Comparator
  42. def thenComparingLong(arg0: ToLongFunction[_ >: A]): Comparator[A]
    Definition Classes
    Comparator
  43. def times(x: A, y: A): A

    times is not a supported Numeric operation for Quantities.

    times is not a supported Numeric operation for Quantities. It is not possible to multiply a dimensional quantity by a like quantity and get another like quantity. Applying this class in a way that uses this method will result in an UnsupportedOperationException being thrown.

    x

    Quantity[A]

    y

    Quantity[A]

    Definition Classes
    AbstractQuantityNumeric → Numeric
    Exceptions thrown

    scala.UnsupportedOperationException for most types

  44. def toDouble(x: A): Double
    Definition Classes
    AbstractQuantityNumeric → Numeric
  45. def toFloat(x: A): Float
    Definition Classes
    AbstractQuantityNumeric → Numeric
  46. def toInt(x: A): Int
    Definition Classes
    AbstractQuantityNumeric → Numeric
  47. def toLong(x: A): Long
    Definition Classes
    AbstractQuantityNumeric → Numeric
  48. def toString(): String
    Definition Classes
    AnyRef → Any
  49. def tryCompare(x: A, y: A): Some[Int]
    Definition Classes
    Ordering → PartialOrdering
  50. val unit: UnitOfMeasure[A] with PrimaryUnit
  51. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  52. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  53. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  54. def zero: A
    Definition Classes
    Numeric

Inherited from Numeric[A]

Inherited from Ordering[A]

Inherited from PartialOrdering[A]

Inherited from Equiv[A]

Inherited from Serializable

Inherited from Serializable

Inherited from Comparator[A]

Inherited from AnyRef

Inherited from Any

Ungrouped