Quantity

abstract class Quantity[A <: Quantity[A]] extends Serializable with Ordered[A]

A base class for measurable quantities, instances of which contain a value and a unit

A base class for measurable quantities, instances of which contain a value and a unit

Authors

garyKeorkunian

Since

0.1

trait Ordered[A]
trait Comparable[A]
trait Serializable
class Object
trait Matchable
class Any

Value members

Abstract methods

The Dimension this quantity represents

The Dimension this quantity represents

The Unit of Measure the value represents

The Unit of Measure the value represents

Returns

UnitOfMeasure[A]

def value: Double

The value of the quantity given the unit

The value of the quantity given the unit

Returns

Double

Concrete methods

def %(that: Double): A
def %(that: A): Double
def *(that: Double): A
def *(that: Price[A]): Money
def +(that: A): A
def +-(that: A): QuantityRange[A]
def -(that: A): A
def /(that: Double): A
def /(that: A): Double
def /%(that: Double): (A, A)
def /%(that: A): (Double, A)
def =~(that: A)(tolerance: A): Boolean

approx

approx

def abs: A

Returns the absolute value of this Quantity

Returns the absolute value of this Quantity

Returns

Quantity

def approx(that: A)(tolerance: A): Boolean

Returns boolean result of approximate equality comparison

Returns boolean result of approximate equality comparison

Value Params
that

Quantity

tolerance

Quantity

def ceil: A

Returns the smallest (closest to negative infinity) Quantity value that is greater than or equal to the argument and is equal to a mathematical integer.

Returns the smallest (closest to negative infinity) Quantity value that is greater than or equal to the argument and is equal to a mathematical integer.

Returns

Quantity

See also

java.lang.Math#ceil(double)

def compare(that: A): Int

Implements Ordered.compare

Implements Ordered.compare

Value Params
that

Quantity

Returns

Int

def divide(that: Double): A

Divide this quantity by some number

Divide this quantity by some number

Value Params
that

Double

Returns

Quantity

def divide(that: A): Double

Divide this quantity by a like quantity

Divide this quantity by a like quantity

Value Params
that

Quantity

Returns

Double

def divideAndRemainder(that: Double): (A, A)

Returns a Pair that includes the result of divideToInteger and remainder

Returns a Pair that includes the result of divideToInteger and remainder

Value Params
that

Double

Returns

(Quantity, Quantity)

def divideAndRemainder(that: A): (Double, A)

Returns a Pair that includes the result of divideToInteger and remainder

Returns a Pair that includes the result of divideToInteger and remainder

Value Params
that

Quantity

Returns

(Double, Quantity)

override def equals(that: Any): Boolean

Override of equals method

Override of equals method

Value Params
that

must be of matching value and unit

Definition Classes
Any
def floor: A

Returns the largest (closest to positive infinity) Quantity value that is less than or equal to the argument and is equal to a mathematical integer

Returns the largest (closest to positive infinity) Quantity value that is less than or equal to the argument and is equal to a mathematical integer

Returns

Quantity

See also

java.lang.Math#floor(double)

override def hashCode(): Int

Override of hashCode

Override of hashCode

Definition Classes
Any
def in(uom: UnitOfMeasure[A]): A

Returns an equivalent Quantity boxed with the supplied Unit

Returns an equivalent Quantity boxed with the supplied Unit

Value Params
uom

UnitOfMeasure[A]

Returns

Quantity

def map(f: Double => Double): A

Applies a function to the underlying value of the Quantity, returning a new Quantity in the same unit

Applies a function to the underlying value of the Quantity, returning a new Quantity in the same unit

Value Params
f

Double => Double function

def max(that: A): A

Returns the max of this and that Quantity

Returns the max of this and that Quantity

Value Params
that

Quantity

Returns

Quantity

def min(that: A): A

Returns the min of this and that Quantity

Returns the min of this and that Quantity

Value Params
that

Quantity

Returns

Quantity

def minus(that: A): A

Subtract two like quantities

Subtract two like quantities

Value Params
that

Quantity

Returns

Quantity

def negate: A

Returns the negative value of this Quantity

Returns the negative value of this Quantity

Returns

Quantity

def notWithin(range: QuantityRange[A]): Boolean

Returns true if this value is not within (contains) the range

Returns true if this value is not within (contains) the range

Value Params
range

QuantityRange

Returns

Boolean

def plus(that: A): A

Add two like quantities

Add two like quantities

Value Params
that

Quantity

Returns

Quantity

def plusOrMinus(that: A): QuantityRange[A]

Returns a QuantityRange representing the range for this value +- that

Returns a QuantityRange representing the range for this value +- that

Value Params
that

Quantity

Returns

QuantityRange

def remainder(that: Double): A

Returns the remainder of a division by a number

Returns the remainder of a division by a number

Value Params
that

Quantity

Returns

Quantity

def remainder(that: A): Double

Returns the remainder of a division by a like quantity

Returns the remainder of a division by a like quantity

Value Params
that

Quantity

Returns

Double

def rint: A

Returns the Quantity value that is closest in value to the argument and is equal to a mathematical integer.

Returns the Quantity value that is closest in value to the argument and is equal to a mathematical integer.

Returns

Quantity

See also

java.lang.Math#rint(double)

def rounded(scale: Int, mode: RoundingMode): A

Returns the Quantity with its coefficient value rounded using scale and mode. The unit is maintained.

Returns the Quantity with its coefficient value rounded using scale and mode. The unit is maintained.

Value Params
mode

RoundingMode - defaults to HALF_EVEN

scale

Int - scale of the value to be returned

Returns

Quantity

def times(that: Double): A

Multiply this quantity by some number

Multiply this quantity by some number

Value Params
that

Double

Returns

Quantity

def to(that: A): QuantityRange[A]

Returns a QuantityRange that goes from this to that

Returns a QuantityRange that goes from this to that

Value Params
that

Quantity

Returns

QuantityRange

def to(uom: UnitOfMeasure[A]): Double

Returns a Double representing the quantity in terms of the supplied unit

Returns a Double representing the quantity in terms of the supplied unit

 val d = Feet(3)
 (d to Inches) should be(36)
Value Params
uom

UnitOfMeasure[A]

Returns

Double

override def toString: String

Returns a string representing the quantity's value in unit

Returns a string representing the quantity's value in unit

Returns

String

Definition Classes
Any
def toString(uom: UnitOfMeasure[A]): String

Returns a string representing the quantity's value in the given unit

Returns a string representing the quantity's value in the given unit

Value Params
uom

UnitOfMeasure[A] with UnitConverter

Returns

String

def toString(uom: UnitOfMeasure[A], format: String): String

Returns a string representing the quantity's value in the given unit in the given format

Returns a string representing the quantity's value in the given unit in the given format

Value Params
format

String containing the format for the value (ie "%.3f")

uom

UnitOfMeasure[A] with UnitConverter

Returns

String

def toTuple: (Double, String)

Returns a tuple representing the numeric value and the unit's symbol

Returns a tuple representing the numeric value and the unit's symbol

def toTuple(uom: UnitOfMeasure[A]): (Double, String)

Returns a pair representing the numeric value and the uom's symbol

Returns a pair representing the numeric value and the uom's symbol

Value Params
uom

UnitOfMeasure[A]

def unary_-: A
def within(range: QuantityRange[A]): Boolean

Returns true if this value is within (contains) the range

Returns true if this value is within (contains) the range

Value Params
range

QuantityRange

Returns

Boolean

def ~=(that: A)(tolerance: A): Boolean

approx

approx

def (that: A)(tolerance: A): Boolean

approx

approx

Inherited methods

def <(that: A): Boolean
Inherited from
Ordered
def <=(that: A): Boolean
Inherited from
Ordered
def >(that: A): Boolean
Inherited from
Ordered
def >=(that: A): Boolean
Inherited from
Ordered
def compareTo(that: A): Int
Inherited from
Ordered