Interface StreamClock.ControllableStreamClock

All Superinterfaces:
InstantSource, StreamClock
All Known Implementing Classes:
ControllableStreamClockImpl
Enclosing interface:
StreamClock

public static interface StreamClock.ControllableStreamClock extends StreamClock
A controllable StreamClock that allows to pin the time to a specific instant or to offset the current system time by some duration.
  • Method Details

    • applyModification

      void applyModification(StreamClock.ControllableStreamClock.Modification modification)
      Modifies the clock by applying the given modification. Previous modifications are overridden and do not stack up.
      Parameters:
      modification - the modification to apply. Use StreamClock.ControllableStreamClock.Modification.none() to reset the clock to current system time.
    • pinAt

      default void pinAt(Instant at)
      Shortcut to pin the clock to a specific instant.
    • offsetBy

      default void offsetBy(Duration by)
      Shortcut to offset the clock by a specific duration.
    • stackOffset

      default void stackOffset(Duration additionalOffset)
      If the clock is already offset, stacks the additional offset on top of the current offset. Otherwise, offsets the clock by the given duration, overwriting any previous modification.
    • reset

      default void reset()
      Shortcut to reset the clock to the current system time.
    • isModified

      default boolean isModified()
      Shortcut to check if the clock is modified. Equivalent to !(currentModification() instanceof Modification.None)