Class NumberDuration

  • All Implemented Interfaces:

    public class NumberDuration
    extends Number
    implements 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-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
    BSD-style license. See Sim0MQ License.

    $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $, initial version Apr 24, 2017
    Alexander Verbraeck
    See Also:
    Serialized Form
    • Constructor Detail

      • NumberDuration

        public NumberDuration​(Number duration)
        Create a duration from a Number.
        duration - the duration as a Number.
      • NumberDuration

        public NumberDuration​(Duration duration)
        Create a duration from a DoubleScalar Duration type.
        duration - the duration as a DoubleScalar Duration.
      • NumberDuration

        public NumberDuration​(FloatDuration duration)
        Create a duration from a FloatScalar FloatDuration type.
        duration - the duration as a FloatScalar FloatDuration.
    • Method Detail

      • instantiate

        public static NumberDuration instantiate​(Object value)
                                          throws Sim0MQException
        Instantiate a NumberDuration based on a value.
        value - the value that can be Duration, FloatDuration, or Number
        an instantiation of NumberDuration
        Sim0MQException - if the value is neither Duration, FloatDuration, nor Number
      • intValue

        public int intValue()
        Specified by:
        intValue in class Number
      • longValue

        public long longValue()
        Specified by:
        longValue in class Number
      • floatValue

        public float floatValue()
        Specified by:
        floatValue in class Number
      • doubleValue

        public double doubleValue()
        Specified by:
        doubleValue in class Number
      • getObject

        public Object getObject()
        Return the NumberDuration as an object, e.g., for serializing.
        NumberDuration as an object
      • getNumber

        public Number getNumber()
        the duration as a Number
      • getDuration

        public Duration getDuration()
        the duration as a djunits Duration type
      • getFloatDuration

        public FloatDuration getFloatDuration()
        the duration as a djunits FloatDuration type