Package de.dlr.proseo.model
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintbooleaninthashCode()merge(SimplePolicy.DeltaTime anotherDeltaTime) Merge two delta times by creating a new delta time with the smaller unit and the larger (converted) durationNormalize delta time to biggest unit, which can be represented with an integer durationlongConvert the delta time to millisecondslongConvert the delta time to seconds (rounded to the nearest second)toString()
-
Field Details
-
duration
public long durationThe duration of the time period in time units (non-negative) -
unit
The time unit applicable for this time period
-
-
Constructor Details
-
DeltaTime
public DeltaTime()No-argument constructor sets delta time to zero days -
DeltaTime
Create a delta time with duration and unit- Parameters:
duration- the delta time durationunit- the delta time unit
-
-
Method Details
-
merge
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
Normalize delta time to biggest unit, which can be represented with an integer duration- Returns:
- the delta time itself for method chaining
-
toString
-
hashCode
public int hashCode() -
equals
-
compareTo
- Specified by:
compareToin interfaceComparable<SimplePolicy.DeltaTime>
-