Quantity

interface Quantity<Q : Quantity<Q, U>, U : Enum<*>> : Comparable<Q> , Parcelable

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.

Types

Link copied to clipboard
enum DecimalsMode : Enum<Quantity.DecimalsMode>

The options for how decimals should be treated in a string representation of a quantity.

Link copied to clipboard
enum SuffixMode : Enum<Quantity.SuffixMode>

The options for how a unit should be suffixed in a string representation of a quantity.

Functions

Link copied to clipboard
abstract fun abs(): Q

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

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

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

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

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

Link copied to clipboard
abstract 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 operator fun times(factor: Double): Q
abstract operator fun times(factor: Int): Q

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

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

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

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

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

Link copied to clipboard
abstract fun toString(unit: U, decimals: Int = 0, suffixMode: Quantity.SuffixMode = SuffixMode.NOT_SEPARATED, decimalsMode: Quantity.DecimalsMode = DecimalsMode.EXACT): String

Returns a string representation for the value from this with the given unit. Depending on decimalsMode, it will show either exactly or at most decimals amount of decimals after the separator. The unit will be suffixed depending on suffixMode.

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

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

Inherited functions

Link copied to clipboard
abstract operator fun compareTo(other: Q): Int
Link copied to clipboard
abstract fun describeContents(): Int
Link copied to clipboard
abstract fun writeToParcel(p0: Parcel, p1: Int)

Inheritors

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard