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 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​(String anInternalsString)` | Constructor using a data string previously generated by `getValuesAsString()`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `LocalDateTime` | `calculateCurrentDateTime()` | Calculates the current date/time according to the states' parameters.
    `ZonedDateTime` | `calculateCurrentZonedDateTime()` | Calculates the current date/time according to the states' parameters.
    `double` | `getProgressionFactor()` |
    `long` | `getRealtimeDecouplingTime()` |
    `long` | `getRealtimeOffset()` |
    `String` | `getValuesAsString()` | Returns the values of this `TimeSyncState` as a String.
    `TimeSyncState` | `plus​(List<org.eclipse.xtext.util.Pair<Long,​TemporalUnit>> aDiffTime)` | Returns a new instance of this `TimeSyncState` to which the given duration was added.
    `String` | `toString()` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### 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 by `getValuesAsString()`.
      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 this `TimeSyncState` as a String. This string is intended to be fed into another `TimeSyncState` 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​(List<org.eclipse.xtext.util.Pair<Long,​TemporalUnit>> aDiffTime)

      Returns a new instance of this `TimeSyncState` 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 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:

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`