Class AbstractDoubleScalar<U extends Unit<U>,S extends AbstractDoubleScalar<U,S>>
- java.lang.Object
-
- java.lang.Number
-
- org.djunits.value.AbstractScalar<U,S>
-
- org.djunits.value.vdouble.scalar.base.AbstractDoubleScalar<U,S>
-
- Type Parameters:
U
- the unitS
- the type
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable<S>
,Scalar<U,S>
,ValueFunctions<U,S>
,Value<U,S>
,DoubleScalarInterface<U,S>
- Direct Known Subclasses:
AbstractDoubleScalarAbs
,AbstractDoubleScalarRel
public abstract class AbstractDoubleScalar<U extends Unit<U>,S extends AbstractDoubleScalar<U,S>> extends AbstractScalar<U,S> implements DoubleScalarInterface<U,S>
The most basic abstract class for the DoubleScalar.Copyright (c) 2013-2023 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUNITS License.- Author:
- Alexander Verbraeck, Peter Knoppers
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.djunits.value.vdouble.scalar.base.DoubleScalarInterface
DoubleScalarInterface.Abs<AU extends AbsoluteLinearUnit<AU,RU>,A extends DoubleScalarInterface.Abs<AU,A,RU,R>,RU extends Unit<RU>,R extends DoubleScalarInterface.RelWithAbs<AU,A,RU,R>>, DoubleScalarInterface.Rel<U extends Unit<U>,R extends DoubleScalarInterface.Rel<U,R>>, DoubleScalarInterface.RelWithAbs<AU extends AbsoluteLinearUnit<AU,RU>,A extends DoubleScalarInterface.Abs<AU,A,RU,R>,RU extends Unit<RU>,R extends DoubleScalarInterface.RelWithAbs<AU,A,RU,R>>
-
Nested classes/interfaces inherited from interface org.djunits.value.base.Scalar
Scalar.Abs<AU extends AbsoluteLinearUnit<AU,RU>,A extends Scalar.Abs<AU,A,RU,R>,RU extends Unit<RU>,R extends Scalar.RelWithAbs<AU,A,RU,R>>, Scalar.Rel<U extends Unit<U>,R extends Scalar.Rel<U,R>>, Scalar.RelWithAbs<AU extends AbsoluteLinearUnit<AU,RU>,A extends Scalar.Abs<AU,A,RU,R>,RU extends Unit<RU>,R extends Scalar.RelWithAbs<AU,A,RU,R>>
-
-
Field Summary
Fields Modifier and Type Field Description double
si
The value, stored in the standard SI unit.
-
Constructor Summary
Constructors Constructor Description AbstractDoubleScalar(U unit, double si)
Construct a new AbstractDoubleScalar.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(S o)
double
doubleValue()
boolean
eq(S o)
Test if this DoubleScalar is equal to a DoubleScalar.boolean
eq0()
Test if this DoubleScalar is equal to 0.0.boolean
equals(Object obj)
float
floatValue()
boolean
ge(S o)
Test if this DoubleScalar is greater than a DoubleScalar.boolean
ge0()
Test if this DoubleScalar is greater than 0.0.double
getInUnit()
Retrieve the value in the original unit.double
getInUnit(U targetUnit)
Retrieve the value converted into some specified unit.double
getSI()
Retrieve the value in the underlying SI unit.boolean
gt(S o)
Test if this DoubleScalar is greater than or equal to a DoubleScalar.boolean
gt0()
Test if this DoubleScalar is greater than or equal to 0.0.int
hashCode()
int
intValue()
boolean
le(S o)
Test if this DoubleScalar is less than or equal to another DoubleScalar.boolean
le0()
Test if this DoubleScalar is less than or equal to 0.0.long
longValue()
boolean
lt(S o)
Test if this DoubleScalar is less than another DoubleScalar.boolean
lt0()
Test if this DoubleScalar is less than 0.0.boolean
ne(S o)
Test if this DoubleScalar is not equal to a DoubleScalar.boolean
ne0()
Test if this DoubleScalar is not equal to 0.0.String
toDisplayString()
Concise display description of this value, without the engineering formatting, so without trailing zeroes.String
toDisplayString(U displayUnit)
Concise display description of this value, without the engineering formatting, so without trailing zeroes.String
toString()
Concise description of this value.String
toString(boolean verbose, boolean withUnit)
Somewhat verbose description of this value with optional type and unit information.String
toString(U displayUnit)
Somewhat verbose description of this value with the values expressed in the specified unit.String
toString(U displayUnit, boolean verbose, boolean withUnit)
Somewhat verbose description of this value with the values expressed in the specified unit.String
toStringSIPrefixed()
Format this AbstractDoubleScalar in SI unit using prefixes when possible.String
toStringSIPrefixed(int smallestPower, int biggestPower)
Format this AbstractDoubleScalar in SI unit using prefixes when possible and within the specified size range.String
toTextualString()
Concise textual representation of this value, without the engineering formatting, so without trailing zeroes.String
toTextualString(U displayUnit)
Concise textual representation of this value, without the engineering formatting, so without trailing zeroes.-
Methods inherited from class org.djunits.value.AbstractScalar
getDisplayUnit, isAbsolute, isRelative, setDisplayUnit
-
Methods inherited from class java.lang.Number
byteValue, shortValue
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.djunits.value.Value
getDisplayUnit, isAbsolute, isRelative, setDisplayUnit
-
-
-
-
Constructor Detail
-
AbstractDoubleScalar
AbstractDoubleScalar(U unit, double si)
Construct a new AbstractDoubleScalar.- Parameters:
unit
- U; the unitsi
- double; the si value to store
-
-
Method Detail
-
getSI
public final double getSI()
Retrieve the value in the underlying SI unit.- Specified by:
getSI
in interfaceDoubleScalarInterface<U extends Unit<U>,S extends AbstractDoubleScalar<U,S>>
- Returns:
- double
-
getInUnit
public final double getInUnit()
Retrieve the value in the original unit.- Specified by:
getInUnit
in interfaceDoubleScalarInterface<U extends Unit<U>,S extends AbstractDoubleScalar<U,S>>
- Returns:
- double
-
getInUnit
public final double getInUnit(U targetUnit)
Retrieve the value converted into some specified unit.- Specified by:
getInUnit
in interfaceDoubleScalarInterface<U extends Unit<U>,S extends AbstractDoubleScalar<U,S>>
- Parameters:
targetUnit
- U; the unit to convert the value into- Returns:
- double
-
lt
public final boolean lt(S o)
Test if this DoubleScalar is less than another DoubleScalar.
-
le
public final boolean le(S o)
Test if this DoubleScalar is less than or equal to another DoubleScalar.
-
gt
public final boolean gt(S o)
Test if this DoubleScalar is greater than or equal to a DoubleScalar.- Specified by:
gt
in interfaceScalar<U extends Unit<U>,S extends AbstractDoubleScalar<U,S>>
- 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 other; false if this is not greater than or equal to other
-
ge
public final boolean ge(S o)
Test if this DoubleScalar is greater than a DoubleScalar.
-
eq
public final boolean eq(S o)
Test if this DoubleScalar is equal to a DoubleScalar.
-
ne
public final boolean ne(S o)
Test if this DoubleScalar is not equal to a DoubleScalar.
-
lt0
public final boolean lt0()
Test if this DoubleScalar is less than 0.0.
-
le0
public final boolean le0()
Test if this DoubleScalar is less than or equal to 0.0.
-
gt0
public final boolean gt0()
Test if this DoubleScalar is greater than or equal to 0.0.
-
ge0
public final boolean ge0()
Test if this DoubleScalar is greater than 0.0.
-
eq0
public final boolean eq0()
Test if this DoubleScalar is equal to 0.0.
-
ne0
public final boolean ne0()
Test if this DoubleScalar is not equal to 0.0.
-
compareTo
public final int compareTo(S o)
- Specified by:
compareTo
in interfaceComparable<U extends Unit<U>>
-
floatValue
public float floatValue()
- Specified by:
floatValue
in classNumber
-
doubleValue
public double doubleValue()
- Specified by:
doubleValue
in classNumber
-
toString
public String toString()
Concise description of this value.
-
toString
public String toString(U displayUnit)
Somewhat verbose description of this value with the values expressed in the specified unit.
-
toString
public String toString(boolean verbose, boolean withUnit)
Somewhat verbose description of this value with optional type and unit information.- Specified by:
toString
in interfaceValue<U extends Unit<U>,S extends AbstractDoubleScalar<U,S>>
- Parameters:
verbose
- boolean; if true; include type info; if false; exclude type infowithUnit
- boolean; if true; include the unit; of false; exclude the unit- Returns:
- String; printable string with the value contents
-
toString
public String toString(U displayUnit, boolean verbose, boolean withUnit)
Somewhat verbose description of this value with the values expressed in the specified unit.- Specified by:
toString
in interfaceValue<U extends Unit<U>,S extends AbstractDoubleScalar<U,S>>
- Parameters:
displayUnit
- U; the unit into which the values are converted for displayverbose
- boolean; if true; include type info; if false; exclude type infowithUnit
- boolean; if true; include the unit; of false; exclude the unit- Returns:
- String; printable string with the value contents
-
toStringSIPrefixed
public String toStringSIPrefixed()
Format this AbstractDoubleScalar in SI unit using prefixes when possible. If the value is too small or too large, e-notation and the plain SI unit are used.- Returns:
- String; formatted value of this AbstractDoubleScalar
-
toStringSIPrefixed
public String toStringSIPrefixed(int smallestPower, int biggestPower)
Format this AbstractDoubleScalar in SI unit using prefixes when possible and within the specified size range. If the value is too small or too large, e-notation and the plain SI unit are used.- Parameters:
smallestPower
- int; the smallest exponent value that will be written using an SI prefixbiggestPower
- int; the largest exponent value that will be written using an SI prefix- Returns:
- String; formatted value of this AbstractDoubleScalar
-
toTextualString
public String 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.- Specified by:
toTextualString
in interfaceScalar<U extends Unit<U>,S extends AbstractDoubleScalar<U,S>>
- Returns:
- a String with the value with the default textual representation of the unit attached.
-
toTextualString
public String toTextualString(U displayUnit)
Concise textual representation of this value, without the engineering formatting, so without trailing zeroes. A space is added between the number and the unit.- Specified by:
toTextualString
in interfaceScalar<U extends Unit<U>,S extends AbstractDoubleScalar<U,S>>
- 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
public String 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.- Specified by:
toDisplayString
in interfaceScalar<U extends Unit<U>,S extends AbstractDoubleScalar<U,S>>
- Returns:
- a String with the value with the default display representation of the unit attached.
-
toDisplayString
public String toDisplayString(U displayUnit)
Concise display description of this value, without the engineering formatting, so without trailing zeroes. A space is added between the number and the unit.- Specified by:
toDisplayString
in interfaceScalar<U extends Unit<U>,S extends AbstractDoubleScalar<U,S>>
- 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.
-
-