Package org.djunits.value.base
Class Scalar<U extends Unit<U>,S extends Scalar<U,S>>
java.lang.Object
java.lang.Number
org.djunits.value.base.Scalar<U,S>
- Type Parameters:
U
- the unitS
- the scalar type with the given unit
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable<S>
,Value<U,
S>
- Direct Known Subclasses:
DoubleScalar
,FloatScalar
public abstract class Scalar<U extends Unit<U>,S extends Scalar<U,S>>
extends Number
implements Value<U,S>, Comparable<S>
Scalar to distinguish a scalar from vectors and matrices.
Copyright (c) 2019-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUNITS License.
- Author:
- Alexander Verbraeck
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract boolean
Test if this DoubleScalar is equal to another DoubleScalar.abstract boolean
eq0()
Test if this DoubleScalar is equal to 0.0.format
(double d) Format a string according to the current locale and the standard (minimized) format, such as "3.14" or "300.0".Format a string according to the current locale and the provided format string.abstract boolean
Test if this DoubleScalar is greater than or equal to another DoubleScalar.abstract boolean
ge0()
Test if this DoubleScalar is greater than or equal to 0.0.final U
Retrieve the unit of this Value.abstract boolean
Test if this DoubleScalar is greater than another DoubleScalar.abstract boolean
gt0()
Test if this DoubleScalar is greater than 0.0.abstract boolean
Test if this DoubleScalar is less than or equal to another DoubleScalar.abstract boolean
le0()
Test if this DoubleScalar is less than or equal to 0.0.abstract boolean
Test if this DoubleScalar is less than another DoubleScalar.abstract boolean
lt0()
Test if this DoubleScalar is less than 0.0.abstract boolean
Test if this DoubleScalar is not equal to another DoubleScalar.abstract boolean
ne0()
Test if this DoubleScalar is not equal to 0.0.void
setDisplayUnit
(U newUnit) Set a new display unit for the value.abstract String
Concise display description of this value, without the engineering formatting, so without trailing zeroes.abstract String
toDisplayString
(U displayUnit) Concise display description of this value, without the engineering formatting, so without trailing zeroes.abstract String
Concise textual representation of this value, without the engineering formatting, so without trailing zeroes.abstract String
toTextualString
(U displayUnit) Concise textual representation of this value, without the engineering formatting, so without trailing zeroes.Methods inherited from class java.lang.Number
byteValue, doubleValue, floatValue, intValue, longValue, shortValue
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Comparable
compareTo
-
Constructor Details
-
Scalar
Construct a new Scalar.- Parameters:
displayUnit
- U; the unit of the new AbstractScalar
-
-
Method Details
-
getDisplayUnit
Description copied from interface:Value
Retrieve the unit of this Value. -
setDisplayUnit
Description copied from interface:Value
Set a new display unit for the value. Internally, the value will stay stored in the default or SI unit. -
lt
Test if this DoubleScalar is less than another DoubleScalar.- Parameters:
o
- T, a relative typed DoubleScalar; the right hand side operand of the comparison- Returns:
- boolean; true if this is less than o; false otherwise
-
le
Test if this DoubleScalar is less than or equal to another DoubleScalar.- Parameters:
o
- T, a relative typed DoubleScalar; the right hand side operand of the comparison- Returns:
- boolean; true if this is less than or equal to o; false otherwise
-
gt
Test if this DoubleScalar is greater than another DoubleScalar.- Parameters:
o
- T, a relative typed DoubleScalar; the right hand side operand of the comparison- Returns:
- boolean; true if this is greater than o; false otherwise
-
ge
Test if this DoubleScalar is greater than or equal to another DoubleScalar.- Parameters:
o
- T, a relative typed DoubleScalar; the right hand side operand of the comparison- Returns:
- boolean; true if this is greater than or equal to o; false otherwise
-
eq
Test if this DoubleScalar is equal to another DoubleScalar.- Parameters:
o
- T, a relative typed DoubleScalar; the right hand side operand of the comparison- Returns:
- boolean; true if this is equal to o; false otherwise
-
ne
Test if this DoubleScalar is not equal to another DoubleScalar.- Parameters:
o
- T, a relative typed DoubleScalar; the right hand side operand of the comparison- Returns:
- boolean; true if this is not equal to o; false otherwise
-
lt0
public abstract boolean lt0()Test if this DoubleScalar is less than 0.0.- Returns:
- boolean; true if this is less than 0.0; false if this is not less than 0.0
-
le0
public abstract boolean le0()Test if this DoubleScalar is less than or equal to 0.0.- Returns:
- boolean; true if this is less than or equal to 0.0; false if this is not less than or equal to 0.0
-
gt0
public abstract boolean gt0()Test if this DoubleScalar is greater than 0.0.- Returns:
- boolean; true if this is greater than 0.0; false if this is not greater than 0.0
-
ge0
public abstract boolean ge0()Test if this DoubleScalar is greater than or equal to 0.0.- Returns:
- boolean; true if this is greater than or equal to 0.0; false if this is not greater than or equal to 0.0
-
eq0
public abstract boolean eq0()Test if this DoubleScalar is equal to 0.0.- Returns:
- boolean; true if this is equal to 0.0; false if this is not equal to 0.0
-
ne0
public abstract boolean ne0()Test if this DoubleScalar is not equal to 0.0.- Returns:
- boolean; true if this is not equal to 0.0; false if this is equal to 0.0
-
toTextualString
Concise textual representation of this value, without the engineering formatting, so without trailing zeroes. A space is added between the number and the unit.- Returns:
- a String with the value with the default textual representation of the unit attached.
-
toTextualString
Concise textual representation of this value, without the engineering formatting, so without trailing zeroes. A space is added between the number and the unit.- Parameters:
displayUnit
- U; the display unit for the value- Returns:
- a String with the value with the default textual representation of the provided unit attached.
-
toDisplayString
Concise display description of this value, without the engineering formatting, so without trailing zeroes. A space is added between the number and the unit.- Returns:
- a String with the value with the default display representation of the unit attached.
-
toDisplayString
Concise display description of this value, without the engineering formatting, so without trailing zeroes. A space is added between the number and the unit.- Parameters:
displayUnit
- U; the display unit for the value- Returns:
- a String with the value with the default display representation of the provided unit attached.
-
format
Format a string according to the current locale and the standard (minimized) format, such as "3.14" or "300.0".- Parameters:
d
- double; the number to format- Returns:
- String; the formatted number using the current Locale
-
format
Format a string according to the current locale and the provided format string.- Parameters:
d
- double; the number to formatformat
- String; the formatting string to use for the number- Returns:
- String; the formatted number using the current Locale and the format string
-