AbstractXClock implements XClock<F> { @Override public final int compareTo( final XClock<F> other) { LOGGER.trace("begin {}.compareTo({})", new Object[] { getClass().getSimpleName(), other }); _timeLock.lock(); try { final int rval; if (other == null) { throw new NullPointerException("cannot compare to a null"); } rval = _time.compareTo(other.getTime()); LOGGER.trace("will return: {}", rval); LOGGER.trace("end {}.compareTo()", getClass().getSimpleName()); return rval; } finally { _timeLock.unlock(); } } protected  AbstractXClock(
            final long tick,
            final F phase,
            final F[] allPhases); protected  AbstractXClock(
            final F[] allPhases); @Override final XTime<F> getTime(); @Override final XTime<F> increment(); @Override void setTime(
            final XTime<F> time); @Override final int compareTo(
            final XClock<F> other); @Override final boolean equals(
            final Object obj); @Override final int hashCode(); @Override final String toString();  }
@Override @Test public final void compareToLargerPhase() { final AbstractXClockImpl clock = new AbstractXClockImpl(1, PhaseImpl.PHASE_1, PhaseImpl.values()); final AbstractXClockImpl largerPhaseClock = new AbstractXClockImpl(1, PhaseImpl.PHASE_2, PhaseImpl.values()); assertThat(clock.compareTo(largerPhaseClock), is(lessThan(0))); }
@Override @Test(expectedExceptions = { NullPointerException.class }) public final void compareToNull() { new AbstractXClockImpl(1, PhaseImpl.PHASE_1, PhaseImpl.values()) .compareTo(null); }
@Override @Test public final void compareToIdentical() { final AbstractXClockImpl clock = new AbstractXClockImpl(PhaseImpl .values()); assertThat(clock.compareTo(clock), is(0)); }
@Override @Test public final void compareToSameTime() { final AbstractXClockImpl clock = new AbstractXClockImpl(1, PhaseImpl.PHASE_1, PhaseImpl.values()); final AbstractXClockImpl sameClock = new AbstractXClockImpl(1, PhaseImpl.PHASE_1, PhaseImpl.values()); assertThat(clock.compareTo(sameClock), is(0)); }
@Override @Test public final void compareToSmallerTick() { final AbstractXClockImpl clock = new AbstractXClockImpl(1, PhaseImpl.PHASE_1, PhaseImpl.values()); final AbstractXClockImpl smallerTickClock = new AbstractXClockImpl(0, PhaseImpl.PHASE_1, PhaseImpl.values()); assertThat(clock.compareTo(smallerTickClock), is(greaterThan(0))); }
@Override @Test public final void compareToSmallerPhase() { final AbstractXClockImpl clock = new AbstractXClockImpl(1, PhaseImpl.PHASE_2, PhaseImpl.values()); final AbstractXClockImpl smallerPhaseClock = new AbstractXClockImpl(1, PhaseImpl.PHASE_1, PhaseImpl.values()); assertThat(clock.compareTo(smallerPhaseClock), is(greaterThan(0))); }
@Override @Test public final void compareToLargerTick() { final AbstractXClockImpl clock = new AbstractXClockImpl(1, PhaseImpl.PHASE_1, PhaseImpl.values()); final AbstractXClockImpl largerTickClock = new AbstractXClockImpl(2, PhaseImpl.PHASE_1, PhaseImpl.values()); assertThat(clock.compareTo(largerTickClock), is(lessThan(0))); }