Class ManualClock

java.lang.Object
me.ahoo.cosid.store.tck.ManualClock
All Implemented Interfaces:
me.ahoo.cosid.time.TimeSource

public final class ManualClock extends Object implements me.ahoo.cosid.time.TimeSource
A clock that moves only when told to, in either direction: the store clock of an InMemoryStore or the client clock of a generator under test. Thread-safe.
  • Field Summary

    Fields inherited from interface me.ahoo.cosid.time.TimeSource

    SYSTEM
  • Constructor Summary

    Constructors
    Constructor
    Description
    A clock at the current system time.
    ManualClock(long startMillis)
    A clock at startMillis.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    advance(Duration amount)
    Moves the time by amount; a negative amount moves it back.
    long
     
    void
    set(long newMillis)
    Sets the time, forwards or backwards.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ManualClock

      public ManualClock(long startMillis)
      A clock at startMillis.
      Parameters:
      startMillis - milliseconds since the Unix epoch
    • ManualClock

      public ManualClock()
      A clock at the current system time.
  • Method Details

    • currentMillis

      public long currentMillis()
      Specified by:
      currentMillis in interface me.ahoo.cosid.time.TimeSource
    • set

      public void set(long newMillis)
      Sets the time, forwards or backwards.
      Parameters:
      newMillis - milliseconds since the Unix epoch
    • advance

      public long advance(Duration amount)
      Moves the time by amount; a negative amount moves it back.
      Parameters:
      amount - how far to move
      Returns:
      the new time