Class SchedulerClock
java.lang.Object
java.time.Clock
com.couchbase.client.core.scheduler.SchedulerClock
Clock adapter around
Scheduler. That adoption gives better integration with
Java 8 DateTime API.
This feature may be useful for testing purpose, especially for integration with
VirtualTimeScheduler. For example:
VirtualTimeScheduler scheduler = VirtualTimeScheduler.create();
SchedulerClock clock = SchedulerClock.of(scheduler);
ZonedDateTime beforeAdvance = ZonedDateTime.now(clock);
scheduler.advanceTimeBy(Duration.ofSeconds(1));
ZonedDateTime afterAdvance = ZonedDateTime.now(clock);
Assert.assertTrue(beforeAdvance.isBefore(afterAdvance));
- Since:
- 3.1.4
- Author:
- Oleh Dokuka, Peter Royal
-
Method Summary
Modifier and TypeMethodDescriptionbooleanreactor.core.scheduler.SchedulerReturn wrapped Scheduler instancegetZone()inthashCode()instant()Gets the current instant of the clock.longmillis()static SchedulerClockof(reactor.core.scheduler.Scheduler scheduler) static SchedulerClocktoString()withScheduler(reactor.core.scheduler.Scheduler scheduler) Builder method that returns new instance ofSchedulerClockwhich is constructed from oldZoneIdand passedSchedulerinstanceMethods inherited from class java.time.Clock
fixed, offset, system, systemDefaultZone, systemUTC, tick, tickMinutes, tickSeconds
-
Method Details
-
getZone
-
withZone
-
getScheduler
@NonNull public reactor.core.scheduler.Scheduler getScheduler()Return wrapped Scheduler instance- Returns:
Schedulerinstance
-
withScheduler
Builder method that returns new instance ofSchedulerClockwhich is constructed from oldZoneIdand passedSchedulerinstance- Returns:
SchedulerClockinstance
-
millis
public long millis() -
instant
Gets the current instant of the clock.This returns an instant representing the current instant as defined by the clock.
Note: If scheduler does not support time in nanoseconds the returned
Instantwill be limited by milliseconds -
equals
-
hashCode
public int hashCode() -
toString
-
of
- Parameters:
scheduler-Schedulerinstance- Returns:
- new
SchedulerClock
-
of
@NonNull public static SchedulerClock of(@NonNull reactor.core.scheduler.Scheduler scheduler, @NonNull ZoneId zoneId) - Parameters:
scheduler-Schedulerinstance- Returns:
- new
SchedulerClock
-