SimpleXTime implements XTime<F> { @Override public final boolean equals( final Object obj) { LOGGER.trace("begin {}.equals({})", new Object[] { getClass().getSimpleName(), obj }); final boolean rval; if (obj == this) { rval = true; } else if ((obj == null) || !(obj instanceof XTime<?>)) { rval = false; } else { final XTime<?> other = (XTime<?>)obj; rval = new EqualsBuilder() .append(_tick, other.getTick()) .append(_phase, other.getPhase()) .isEquals(); } LOGGER.trace("will return: {}", rval); LOGGER.trace("end {}.equals()", getClass().getSimpleName()); return rval; } SimpleXTime(
            final long tick,
            final F phase); @Override final long getTick(); @Override final F getPhase(); @Override final int compareTo(
            final XTime<F> other); @Override final boolean equals(
            final Object obj); @Override final int hashCode(); @Override final String toString();  }
@Test public final void equalsIdentical() { final SimpleXTime<PhaseImpl> time = new SimpleXTime<PhaseImpl>(1, PhaseImpl.PHASE_1); assertThat(time.equals(time), is(true)); }
@Test public final void equalsSameTickAndPhase() { final SimpleXTime<PhaseImpl> time = new SimpleXTime<PhaseImpl>(1, PhaseImpl.PHASE_1); final SimpleXTime<PhaseImpl> sameTime = new SimpleXTime<PhaseImpl>(1, PhaseImpl.PHASE_1); assertThat(time.equals(sameTime), is(true)); }
@Test public final void equalsDifferentTick() { final SimpleXTime<PhaseImpl> time = new SimpleXTime<PhaseImpl>(1, PhaseImpl.PHASE_1); final SimpleXTime<PhaseImpl> differentTickTime = new SimpleXTime<PhaseImpl>( 0, PhaseImpl.PHASE_1); assertThat(time.equals(differentTickTime), is(false)); }
@Test public final void equalsDifferentPhase() { final SimpleXTime<PhaseImpl> time = new SimpleXTime<PhaseImpl>(1, PhaseImpl.PHASE_2); final SimpleXTime<PhaseImpl> differentPhaseTime = new SimpleXTime<PhaseImpl>( 1, PhaseImpl.PHASE_1); assertThat(time.equals(differentPhaseTime), is(false)); }
@Test public final void equalsNull() { assertThat(new SimpleXTime<PhaseImpl>(1, PhaseImpl.PHASE_1) .equals((XClock<?>)null), is(false)); }
@Test public final void equalsNonTime() { assertThat(new SimpleXTime<PhaseImpl>(1, PhaseImpl.PHASE_1) .equals("not a time"), is(false)); }