Temperature class

Represents a "thermometer" temperature.

This is distinguished from a change in temperature because of the fact that temperature scales are not zero-based. To represent a change in temperature instead, and for an in-depth explanation of this requirement, see the TemperatureChange class documentation.

Several operations on the Temperature class work with TemperatureChange instances instead of Temperature instances. This is because the natural way to think about those operations is in terms of temperature changes. For example, the + operator applies a change in temperature rather than a "thermometer" temperature. While physicists may intend to actually add two "thermometer" temperatures together in some cases, this is not the common meaning of "adding temperature," so the more esoteric uses are supported with special methods rather than the built-in operators. Pay special attention to the operations in this class to ensure proper use of the library. The type system should catch most errors, e.g. adding together two "thermometer" temperatures with the + operator.

Implemented types

Constructors

Temperature.absoluteZero([MeasurementInterpreter<TemperatureChange> defaultInterpreter = TemperatureChangeInterpreter._kelvin])
Absolute zero.
const
Temperature.infinite([MeasurementInterpreter<TemperatureChange> defaultInterpreter = TemperatureChangeInterpreter._kelvin])
Infinite temperature.
const
Temperature.ofCelcius(num celcius, {Precision precision = Precision.max})
Constructs a Temperature from a degree Celcius amount.
Temperature.ofFahrenheit(num fahrenheit, {Precision precision = Precision.max})
Constructs a Temperature from a degree Fahrenheit amount.
Temperature.ofKelvin(num kelvin, {Precision precision = Precision.max})
Constructs a Temperature from a Kelvin amount.

Properties

asCelcius double
Interprets this as degrees Celcius.
no setter
asFahrenheit double
Interprets this as degrees Fahrenheit.
no setter
asKelvin double
Interprets this as Kelvin.
no setter
hashCode int
The hash code for this object.
no setteroverride
isFinite bool
Returns true if this is finite.
no setter
isInfinite bool
Returns true if this is infinite.
no setter
precision int
Returns the digits of precision this measurement has.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

acceptVisitor(MeasurementVisitor visitor) → void
Accept a measurement visitor.
compareTo(Temperature other) int
Compares this object to another object.
override
difference(Temperature other) TemperatureChange
Returns the difference between this and another Temperature.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override
withDefaultUnit(MeasurementInterpreter<TemperatureChange> interpreter) Temperature
Constructs a new measurement equivalent to this one but with a different default measurement unit.
withPrecision(Precision precision) Temperature
Constructs a new measurement equivalent to this one but with a different precision.

Operators

operator +(TemperatureChange change) Temperature
Creates a Temperature representing the application of a Temperature and a TemperatureChange.
operator -(TemperatureChange change) Temperature
Creates a Temperature representing the application of a Temperature and the opposite of a TemperatureChange.
operator <(Temperature other) bool
Returns true if this is smaller than the other Temperature.
operator <=(Temperature other) bool
Returns true if this is smaller than or equal to the other Temperature.
operator ==(Object other) bool
The equality operator.
override
operator >(Temperature other) bool
Returns true if this is larger than the other Temperature.
operator >=(Temperature other) bool
Returns true if this is larger than or equal to the other Temperature.