Quantity

A base interface for quantities. Outlines the common operations to retrieve values and perform mathematical operations.

Parameters

Q

The quantity type implementing this interface.

U

An enum type that contains the units that the quantity's values can be in.

Inheritors

Types

Link copied to clipboard
object Companion
Link copied to clipboard
data class FormattedQuantity(val value: Double, val symbol: String)

Output structure of format.

Properties

Link copied to clipboard
abstract val rawValue: Long

Raw unformatted value.

Functions

Link copied to clipboard
open fun abs(): Q

Returns a new instance with the value from this as absolute value.

Link copied to clipboard
open operator override fun compareTo(other: Q): Int

Compares this object with the other object.

Link copied to clipboard
open operator fun div(divisor: Q): Double
open operator fun div(divisor: Double): Q
open operator fun div(divisor: Int): Q

Returns a new instance with the value from this divided by divisor.

Link copied to clipboard

Returns a FormattedQuantity representation of the value from this in the given unit.

Link copied to clipboard
open operator fun minus(other: Q): Q

Returns a new instance that has other's value subtracted from this.

Link copied to clipboard
open operator fun plus(other: Q): Q

Returns a new instance with a value equal to the sum of values from this and other.

Link copied to clipboard
abstract fun selfFactory(rawValue: Long): Q

Creates a new instance with the provided rawValue.

Link copied to clipboard
open operator fun times(factor: Double): Q
open operator fun times(factor: Int): Q

Returns a new instance with the value from this multiplied by factor.

Link copied to clipboard
open fun toDouble(unit: U): Double

Expresses the value of this under the given unit as a Double.

Link copied to clipboard
open fun toLong(unit: U): Long

Expresses the value of this under the given unit as a Long.

Link copied to clipboard
open operator fun unaryMinus(): Q

Returns a new instance with the value from this as negative.