ImmutableMeasure

open class ImmutableMeasure<U : Unit<U>?> : Measure<U>

A measure holds the magnitude and unit of some dimension, such as distance, time, or speed. An immutable measure is immutable and type safe, making it easy to use in concurrent situations and gives compile-time safety. Two measures with the same unit and magnitude are effectively equivalent objects.

Since

1.0.0-pre

Parameters

<U>

the unit type of the measure

Inherited properties

Link copied to clipboard
The threshold for two measures to be considered equivalent if converted to the same unit.

Functions

Link copied to clipboard
Gets the magnitude of this measure in terms of the base unit.
Link copied to clipboard
open fun copy(): Measure<U>
Returns an immutable copy of this measure.
Link copied to clipboard
open fun equals(o: Any): Boolean
Checks for object equality.
Link copied to clipboard
open fun hashCode(): Int
Link copied to clipboard
open fun magnitude(): Double
Gets the unitless magnitude of this measure.
Link copied to clipboard
open fun <U : Unit<U>?> ofBaseUnits(baseUnitMagnitude: Double, unit: Unit<U>): ImmutableMeasure<U>
Creates a new measure in the given unit with a magnitude equal to the given one in base units.
Link copied to clipboard
open fun <U : Unit<U>?> ofRelativeUnits(relativeMagnitude: Double, unit: Unit<U>): ImmutableMeasure<U>
Creates a new measure in the given unit with a magnitude in terms of that unit.
Link copied to clipboard
open fun toString(): String
Link copied to clipboard
open fun unit(): U
Gets the units of this measure.

Inherited functions

Link copied to clipboard
abstract fun compareTo(p: T): Int
open fun compareTo(o: Measure<U>): Int
Link copied to clipboard
open fun divide(divisor: Double): Measure<U>
Divides this measurement by some constant divisor and returns the result.
open fun <U2 : Unit<U2>?> divide(other: Measure<U2>): Measure<out Any>
Divides this measurement by another measure and performs some dimensional analysis to reduce the units.
Link copied to clipboard
open fun gt(o: Measure<U>): Boolean
Checks if this measure is greater than another measure of the same unit.
Link copied to clipboard
open fun gte(o: Measure<U>): Boolean
Checks if this measure is greater than or equivalent to another measure of the same unit.
Link copied to clipboard
open fun in(unit: Unit<U>): Double
Converts this measure to a measure with a different unit of the same type, eg minutes to seconds.
Link copied to clipboard
open fun inUnit(unit: Unit<U>): Double
Converts this measure to a measure with a different unit of the same type, eg minutes to seconds.
Link copied to clipboard
open fun isEquivalent(other: Measure<out Any>): Boolean
Checks if this measure is equivalent to another measure of the same unit.
Link copied to clipboard
open fun isNear(other: Measure<out Any>, varianceThreshold: Double): Boolean
Checks if this measure is near another measure of the same unit.
open fun isNear(other: Measure<U>, tolerance: Measure<U>): Boolean
Checks if this measure is near another measure of the same unit, with a specified tolerance of the same unit.
Link copied to clipboard
open fun lt(o: Measure<U>): Boolean
Checks if this measure is less than another measure of the same unit.
Link copied to clipboard
open fun lte(o: Measure<U>): Boolean
Checks if this measure is less than or equivalent to another measure of the same unit.
Link copied to clipboard
open fun <U : Unit<U>?> max(measures: Array<Measure<U>>): Measure<U>
Returns the measure with the absolute value closest to positive infinity.
Link copied to clipboard
open fun <U : Unit<U>?> min(measures: Array<Measure<U>>): Measure<U>
Returns the measure with the absolute value closest to negative infinity.
Link copied to clipboard
open fun minus(other: Measure<U>): Measure<U>
Subtracts another measure from this one.
Link copied to clipboard
Creates a new mutable copy of this measure.
Link copied to clipboard
open fun negate(): Measure<U>
Negates this measure and returns the result.
Link copied to clipboard
open fun <U2 : Unit<U2>?> per(denominator: U2): Measure<Per<U, U2>>
Creates a relational measure equivalent to this one per some other unit.
open fun per(period: Measure<Time>): Measure<Velocity<U>>
Creates a velocity measure by dividing this one by a time period measure.
open fun per(time: Time): Measure<Velocity<U>>
Creates a velocity measure equivalent to this one per a unit of time.
Link copied to clipboard
open fun plus(other: Measure<U>): Measure<U>
Adds another measure to this one.
Link copied to clipboard
open fun times(multiplier: Double): Measure<U>
Multiplies this measurement by some constant multiplier and returns the result.
open fun <U2 : Unit<U2>?> times(other: Measure<U2>): Measure<out Any>
Generates a new measure that is equal to this measure multiplied by another.
Link copied to clipboard
open fun toLongString(): String
Returns a string representation of this measurement in a longhand form.
Link copied to clipboard
Returns a string representation of this measurement in a scientific shorthand form.
Link copied to clipboard
open fun toShortString(): String
Returns a string representation of this measurement in the default form.