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-2022 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 doublesiThe 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 intcompareTo(S o)doubledoubleValue()booleaneq(S o)Test if this DoubleScalar is equal to a DoubleScalar.booleaneq0()Test if this DoubleScalar is equal to 0.0.booleanequals(Object obj)floatfloatValue()booleange(S o)Test if this DoubleScalar is greater than a DoubleScalar.booleange0()Test if this DoubleScalar is greater than 0.0.doublegetInUnit()Retrieve the value in the original unit.doublegetInUnit(U targetUnit)Retrieve the value converted into some specified unit.doublegetSI()Retrieve the value in the underlying SI unit.booleangt(S o)Test if this DoubleScalar is greater than or equal to a DoubleScalar.booleangt0()Test if this DoubleScalar is greater than or equal to 0.0.inthashCode()intintValue()booleanle(S o)Test if this DoubleScalar is less than or equal to another DoubleScalar.booleanle0()Test if this DoubleScalar is less than or equal to 0.0.longlongValue()booleanlt(S o)Test if this DoubleScalar is less than another DoubleScalar.booleanlt0()Test if this DoubleScalar is less than 0.0.booleanne(S o)Test if this DoubleScalar is not equal to a DoubleScalar.booleanne0()Test if this DoubleScalar is not equal to 0.0.StringtoDisplayString()Concise display description of this value, without the engineering formatting, so without trailing zeroes.StringtoDisplayString(U displayUnit)Concise display description of this value, without the engineering formatting, so without trailing zeroes.StringtoString()Concise description of this value.StringtoString(boolean verbose, boolean withUnit)Somewhat verbose description of this value with optional type and unit information.StringtoString(U displayUnit)Somewhat verbose description of this value with the values expressed in the specified unit.StringtoString(U displayUnit, boolean verbose, boolean withUnit)Somewhat verbose description of this value with the values expressed in the specified unit.StringtoStringSIPrefixed()Format this AbstractDoubleScalar in SI unit using prefixes when possible.StringtoStringSIPrefixed(int smallestPower, int biggestPower)Format this AbstractDoubleScalar in SI unit using prefixes when possible and within the specified size range.StringtoTextualString()Concise textual representation of this value, without the engineering formatting, so without trailing zeroes.StringtoTextualString(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:
getSIin 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:
getInUnitin 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:
getInUnitin 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:
gtin 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:
compareToin interfaceComparable<U extends Unit<U>>
-
floatValue
public float floatValue()
- Specified by:
floatValuein classNumber
-
doubleValue
public double doubleValue()
- Specified by:
doubleValuein 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:
toStringin 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:
toStringin 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:
toTextualStringin 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:
toTextualStringin 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:
toDisplayStringin 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:
toDisplayStringin 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.
-
-