Class NumberDuration

java.lang.Object
java.lang.Number
org.sim0mq.message.types.NumberDuration
All Implemented Interfaces:
Serializable

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-2024 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
Author:
Alexander Verbraeck
See Also:
  • Constructor Details

    • NumberDuration

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

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

      public NumberDuration(FloatDuration duration)
      Create a duration from a FloatScalar FloatDuration type.
      Parameters:
      duration - the duration as a FloatScalar FloatDuration.
  • Method Details

    • instantiate

      public static NumberDuration instantiate(Object value) throws Sim0MQException
      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()
      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.
      Returns:
      NumberDuration as an object
    • getNumber

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

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

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