Package de.gebit.integrity.runner.time
Class TimeSyncState
- java.lang.Object
-
- de.gebit.integrity.runner.time.TimeSyncState
-
public class TimeSyncState extends 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 TimeSyncStateLIVEThis 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(String anInternalsString)Constructor using a data string previously generated bygetValuesAsString().
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LocalDateTimecalculateCurrentDateTime()Calculates the current date/time according to the states' parameters.ZonedDateTimecalculateCurrentZonedDateTime()Calculates the current date/time according to the states' parameters.doublegetProgressionFactor()longgetRealtimeDecouplingTime()longgetRealtimeOffset()StringgetValuesAsString()Returns the values of thisTimeSyncStateas a String.TimeSyncStateplus(List<org.eclipse.xtext.util.Pair<Long,TemporalUnit>> aDiffTime)Returns a new instance of thisTimeSyncStateto which the given duration was added.StringtoString()
-
-
-
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(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 String getValuesAsString()
Returns the values of thisTimeSyncStateas a String. This string is intended to be fed into anotherTimeSyncStatein 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(List<org.eclipse.xtext.util.Pair<Long,TemporalUnit>> aDiffTime)
Returns a new instance of thisTimeSyncStateto 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
TimeSyncStateinstance
-
calculateCurrentZonedDateTime
public ZonedDateTime calculateCurrentZonedDateTime()
Calculates the current date/time according to the states' parameters.- Returns:
-
calculateCurrentDateTime
public LocalDateTime calculateCurrentDateTime()
Calculates the current date/time according to the states' parameters.- Returns:
-
-