Enum Class Duration

java.lang.Object
java.lang.Enum<Duration>
oracle.communication.brm.charging.util.unit.Duration
All Implemented Interfaces:
Serializable, Comparable<Duration>, Constable, Unit<Duration>

public enum Duration extends Enum<Duration> implements Unit<Duration>
Represents the time duration unit. Each duration unit has an associated symbol and the supported units are:
  1. ms
  2. sec
  3. min
  4. hr
  5. Day
  6. Week
  • Enum Constant Details

    • Millis

      public static final Duration Millis
    • Seconds

      public static final Duration Seconds
    • Minutes

      public static final Duration Minutes
    • Hours

      public static final Duration Hours
    • Days

      public static final Duration Days
    • Weeks

      public static final Duration Weeks
  • Field Details

    • ALLOWABLE_DURATION

      public static final transient EnumSet<Duration> ALLOWABLE_DURATION
  • Method Details

    • values

      public static Duration[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Duration valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getRatio

      @Deprecated public long getRatio(Duration d)
      Deprecated.

      The method returns a negative value if d is smaller than this Unit. For example, if d is Millis and this Unit is in Seconds then the returned value will be 1000. If d is in Seconds and this Unit is in Millis then the returned value is -1000. Negative value is returned to avoid any expensive divisions.

      Specified by:
      getRatio in interface Unit<Duration>
      Parameters:
      d - Duration to find the conversion ration with.
      Returns:
      long The ration between d and this Unit. TODO: this method should be made private, it is still public here to provide backward compatibility to customers who are potentially still using it.
    • valueOf

      public UnitValue<Duration> valueOf(BigDecimal b)
      Returns an instance of the UnitValue with this Unit and provided quantity
      Specified by:
      valueOf in interface Unit<Duration>
      Parameters:
      b - BigDecimal
      Returns:
      UnitValue
    • convert

      public UnitValue<Duration> convert(UnitValue<Duration> otherValue)
      Returns an instance of the UnitValue with this Unit converted according to a specific ratio
      Specified by:
      convert in interface Unit<Duration>
      Parameters:
      otherValue - UnitValue unit value to convert to
      Returns:
      UnitValue unit value resulting from conversion of otherValue to the unit
    • createValueFromUnitString

      public static UnitValue<Duration> createValueFromUnitString(String unitString, BigDecimal theValue)
      helper method used to choose the correct UOM and set the value.
      Parameters:
      unitString - the UOM for the Data value
      theValue - the data value
      Returns:
      the newly created UnitValue from the supplied values.