Package de.gebit.integrity.runner.time
Class TimeSyncState
- java.lang.Object
-
- de.gebit.integrity.runner.time.TimeSyncState
-
public class TimeSyncState extends java.lang.Object
An object encapsulating the necessary internal parameters for fake test time generation.- Author:
- Rene Schneider - initial API and implementation
-
-
Field Summary
Fields Modifier and Type Field Description static TimeSyncState
LIVE
This instance represents live time.
-
Constructor Summary
Constructors Constructor Description TimeSyncState()
Constructs an instance that represents local live time.TimeSyncState(long aRealtimeOffset, long aRealtimeDecouplingTime, double aProgressionFactor)
Constructor.TimeSyncState(java.lang.String anInternalsString)
Constructor using a data string previously generated bygetValuesAsString()
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.time.LocalDateTime
calculateCurrentDateTime()
Calculates the current date/time according to the states' parameters.java.time.ZonedDateTime
calculateCurrentZonedDateTime()
Calculates the current date/time according to the states' parameters.double
getProgressionFactor()
long
getRealtimeDecouplingTime()
long
getRealtimeOffset()
java.lang.String
getValuesAsString()
Returns the values of thisTimeSyncState
as a String.TimeSyncState
plus(java.util.List<org.eclipse.xtext.util.Pair<java.lang.Long,java.time.temporal.TemporalUnit>> aDiffTime)
Returns a new instance of thisTimeSyncState
to which the given duration was added.java.lang.String
toString()
-
-
-
Field Detail
-
LIVE
public static final TimeSyncState LIVE
This instance represents live time.
-
-
Constructor Detail
-
TimeSyncState
public TimeSyncState(long aRealtimeOffset, long aRealtimeDecouplingTime, double aProgressionFactor)
Constructor.- Parameters:
aRealtimeOffset
- The offset from realtime, in msecs since 1.1.1970.aRealtimeDecouplingTime
- The time at which the fake time was decoupled from realtime, in msecs since 1.1.1970.aProgressionFactor
- A time progression factor (1.0 = realtime, 0.0 = frozen).
-
TimeSyncState
public TimeSyncState(java.lang.String anInternalsString)
Constructor using a data string previously generated bygetValuesAsString()
.- Parameters:
anInternalsString
- the string to use as source
-
TimeSyncState
public TimeSyncState()
Constructs an instance that represents local live time.
-
-
Method Detail
-
getProgressionFactor
public double getProgressionFactor()
-
getRealtimeDecouplingTime
public long getRealtimeDecouplingTime()
-
getRealtimeOffset
public long getRealtimeOffset()
-
getValuesAsString
public java.lang.String getValuesAsString()
Returns the values of thisTimeSyncState
as a String. This string is intended to be fed into anotherTimeSyncState
in order to synchronize it with the source. The string consists of pipe-divided values "realtime offset", "realtime decoupling time" and "multiplier" (first two are long values, third is a double-precision floating point number in normal notation with decimal point).- Returns:
- the internal values as string without spaces
-
plus
public TimeSyncState plus(java.util.List<org.eclipse.xtext.util.Pair<java.lang.Long,java.time.temporal.TemporalUnit>> aDiffTime)
Returns a new instance of thisTimeSyncState
to which the given duration was added. This does NOT modify the state that it is called upon!- Parameters:
aDiffTime
- the time to add (negative = subtract)- Returns:
- a new
TimeSyncState
instance
-
calculateCurrentZonedDateTime
public java.time.ZonedDateTime calculateCurrentZonedDateTime()
Calculates the current date/time according to the states' parameters.- Returns:
-
calculateCurrentDateTime
public java.time.LocalDateTime calculateCurrentDateTime()
Calculates the current date/time according to the states' parameters.- Returns:
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-