Class FakeNanoSource
- java.lang.Object
-
- com.pervasivecode.utils.time.testing.FakeNanoSource
-
- All Implemented Interfaces:
CurrentNanosSource
public class FakeNanoSource extends Object implements CurrentNanosSource
This is a fake implementation ofCurrentNanosSource
, intended for use by test code.
-
-
Constructor Summary
Constructors Constructor Description FakeNanoSource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
currentTimeNanoPrecision()
Return the stored fake "current" time value, and increment the stored value by 1.void
incrementTimeNanos(long additionalNanos)
Increment the internal counter by this many fake nanoseconds.
-
-
-
Method Detail
-
incrementTimeNanos
public void incrementTimeNanos(long additionalNanos)
Increment the internal counter by this many fake nanoseconds. Subsequent calls tocurrentTimeNanoPrecision()
will return a value that is at least this much large than the return value from prior calls.- Parameters:
additionalNanos
- The number of fake nanoseconds to advance the internal counter.
-
currentTimeNanoPrecision
public long currentTimeNanoPrecision()
Return the stored fake "current" time value, and increment the stored value by 1.- Specified by:
currentTimeNanoPrecision
in interfaceCurrentNanosSource
- Returns:
- The number of nanoseconds that have elapsed since the Unix epoch.
-
-