- All Implemented Interfaces:
Serializable,Comparable<Speed>,Constable,Dimension,DimensionWithLinearConversion
The various instances of speed …
Because speed is distance per time, the values for
factor()
are calculated based on the values from
Length.factor()
and
Time.factor().
- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: Speed.java 1072 2023-09-30 20:44:38Z tquadrat $
- Since:
- 0.0.4
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.value.Speed"
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionÅngström per Week.Feet per second.Kilometer per hour.Knot (nautical mile per hour).Meter per second.Mile per hour. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BigDecimalThe factor.private final StringThe unit symbol.Fields inherited from interface org.tquadrat.foundation.value.api.DimensionWithLinearConversion
MSG_UnknownUnit -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateSpeed(BigDecimal factor, String unitSymbol) Creates a newSpeedinstance. -
Method Summary
Modifier and TypeMethodDescriptionfinal SpeedbaseUnit()Returns the base unit.final BigDecimalfactor()Returns the factor that is used to convert a value from this unit to the base unit.static final SpeedReturns theSpeedinstance for the given unit.final StringReturns the unit symbol for the dimension as a single line string.static SpeedReturns the enum constant of this class with the specified name.static Speed[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOfMethods inherited from interface org.tquadrat.foundation.value.api.Dimension
equals, getPrecision, name, toString, unitSymbolForPrintingMethods inherited from interface org.tquadrat.foundation.value.api.DimensionWithLinearConversion
fromBase, toBase
-
Enum Constant Details
-
ÅNGSTRÖM_PER_WEEK
Ångström per Week. This is by far not a useful unit for speed, but it is the implementation of a famous instance of Murphy's Laws:
"Units are always provided in the most impractical form, e.g. a speed as Ångström per Week." -
FEET_PER_SECOND
Feet per second. -
KNOT
Knot (nautical mile per hour). -
KILOMETER_PER_HOUR
Kilometer per hour. -
METER_PER_SECOND
Meter per second. -
MILE_PER_HOUR
Mile per hour.
-
-
Field Details
-
m_Factor
The factor. -
m_UnitSymbol
The unit symbol.
-
-
Constructor Details
-
Speed
Creates a newSpeedinstance.- Parameters:
factor- The factor.unitSymbol- The unit symbol.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
baseUnit
Returns the base unit.
E.g. for length, the base unit would be Meter (m), for mass, it is Kilogram (kg), and so on.
-
factor
Returns the factor that is used to convert a value from this unit to the base unit.
For length, if you have to convert a Centimeter value to Meter, you will divide that by 100 or multiply it with a factor of 0.01.
For the base unit, the factor is 1.0.
- Specified by:
factorin interfaceDimensionWithLinearConversion- Returns:
- The factor.
- See Also:
-
forUnit
Returns theSpeedinstance for the given unit.- Parameters:
unitSymbol- The unit symbol.- Returns:
- The respective instance.
- Throws:
IllegalArgumentException- The given unit is unknown.
-
unitSymbol
Returns the unit symbol for the dimension as a single line string.
For a length, this would be "m", for a speed "km/h", and for an acceleration, it could be "m/(s^2)".
- Specified by:
unitSymbolin interfaceDimension- Returns:
- The unit.
-
