DomainClock implements DeviceClock { @Override public DeviceClock.Reading instant() { return new DeviceClock.Reading() { private final Instant ms = currentTime(); @Override public Instant getDeviceTime() { return null; } @Override public boolean hasDeviceTime() { return false; } @Override public Instant getTime() { Instant adjusted = timeSampleArrayResolution(currentArrayResolutionNsPerSample, ms); return adjusted; } @Override public DeviceClock.Reading refineResolutionForFrequency(int hertz, int size) { currentArrayResolutionNsPerSample = ensureResolutionForFrequency(currentArrayResolutionNsPerSample, hertz, size); return this; } }; } DomainClock(DomainParticipant dp); static void toDDSTime(long timestamp, Time_t t); static void toDDSTime(long timestamp, ice.Time_t t); static Time_t toDDSTime(long timestamp); static void toDDSTime(Instant timestamp, Time_t t); static void toDDSTime(Instant timestamp, ice.Time_t t); static Time_t toDDSTime(Instant timestamp); static long toMilliseconds(Time_t timestamp); @Override DeviceClock.Reading instant();  }
@Test public void testClockDecoration() { final long now = System.currentTimeMillis(); DeviceClock ref = new DeviceClock() { @Override public Reading instant() { return new DeviceClock.ReadingImpl(now); } }; DeviceClock epoch = new DeviceClock() { @Override public Reading instant() { return new DeviceClock.ReadingImpl(0); } }; DeviceClock.Reading r = new DeviceClock.CombinedReading(ref.instant(), epoch.instant()); Assert.assertEquals("combined reading should return the reference time", r.getTime(), Instant.ofEpochMilli(now)); Assert.assertTrue("combined reading must contain device time", r.hasDeviceTime()); Assert.assertEquals("invalid value for device time", r.getDeviceTime(), Instant.ofEpochMilli(0)); }