Class SimplePolicy.DeltaTime

java.lang.Object
de.dlr.proseo.model.SimplePolicy.DeltaTime
All Implemented Interfaces:
Comparable<SimplePolicy.DeltaTime>
Enclosing class:
SimplePolicy

@Embeddable public static class SimplePolicy.DeltaTime extends Object implements Comparable<SimplePolicy.DeltaTime>
Class representing a single overlapping time period
  • Field Details

    • duration

      public long duration
      The duration of the time period in time units (non-negative)
    • unit

      public TimeUnit unit
      The time unit applicable for this time period
  • Constructor Details

    • DeltaTime

      public DeltaTime()
      No-argument constructor sets delta time to zero days
    • DeltaTime

      public DeltaTime(long duration, TimeUnit unit)
      Create a delta time with duration and unit
      Parameters:
      duration - the delta time duration
      unit - the delta time unit
  • Method Details

    • merge

      public SimplePolicy.DeltaTime merge(SimplePolicy.DeltaTime anotherDeltaTime)
      Merge two delta times by creating a new delta time with the smaller unit and the larger (converted) duration
      Parameters:
      anotherDeltaTime - the delta time to merge this one with
      Returns:
      a new DeltaTime object with the larger duration
    • toSeconds

      public long toSeconds()
      Convert the delta time to seconds (rounded to the nearest second)
      Returns:
      the duration of the delta time in seconds
    • toMilliseconds

      public long toMilliseconds()
      Convert the delta time to milliseconds
      Returns:
      the duration of the delta time in milliseconds
    • normalize

      public SimplePolicy.DeltaTime normalize()
      Normalize delta time to biggest unit, which can be represented with an integer duration
      Returns:
      the delta time itself for method chaining
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • compareTo

      public int compareTo(SimplePolicy.DeltaTime o)
      Specified by:
      compareTo in interface Comparable<SimplePolicy.DeltaTime>