Package org.sim0mq.message.types
Class NumberDuration
java.lang.Object
java.lang.Number
org.sim0mq.message.types.NumberDuration
- All Implemented Interfaces:
Serializable
Wrapper for a Number or float/double with Unit of type Duration. Store it internally as a Number or as a DoubleScalar,
or as a FloatScalar and have methods to retrieve it in different ways.
Copyright (c) 2016-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See Sim0MQ License.
- Author:
- Alexander Verbraeck
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionNumberDuration
(Number duration) Create a duration from a Number.NumberDuration
(Duration duration) Create a duration from a DoubleScalar Duration type.NumberDuration
(FloatDuration duration) Create a duration from a FloatScalar FloatDuration type. -
Method Summary
Modifier and TypeMethodDescriptiondouble
float
Return the NumberDuration as an object, e.g., for serializing.static NumberDuration
instantiate
(Object value) Instantiate a NumberDuration based on a value.int
intValue()
long
Methods inherited from class java.lang.Number
byteValue, shortValue
-
Constructor Details
-
NumberDuration
Create a duration from a Number.- Parameters:
duration
- the duration as a Number.
-
NumberDuration
Create a duration from a DoubleScalar Duration type.- Parameters:
duration
- the duration as a DoubleScalar Duration.
-
NumberDuration
Create a duration from a FloatScalar FloatDuration type.- Parameters:
duration
- the duration as a FloatScalar FloatDuration.
-
-
Method Details
-
instantiate
Instantiate a NumberDuration based on a value.- Parameters:
value
- the value that can be Duration, FloatDuration, or Number- Returns:
- an instantiation of NumberDuration
- Throws:
Sim0MQException
- if the value is neither Duration, FloatDuration, nor Number
-
intValue
public int intValue() -
longValue
public long longValue() -
floatValue
public float floatValue()- Specified by:
floatValue
in classNumber
-
doubleValue
public double doubleValue()- Specified by:
doubleValue
in classNumber
-
getObject
Return the NumberDuration as an object, e.g., for serializing.- Returns:
- NumberDuration as an object
-
getNumber
- Returns:
- the duration as a Number
-
getDuration
- Returns:
- the duration as a djunits Duration type
-
getFloatDuration
- Returns:
- the duration as a djunits FloatDuration type
-