Trace { public Trace<S, A> reverse() { return Trace.of(states.reverse(), actions.reverse()); } private  Trace(final List<? extends S> states, final List<? extends A> actions); static Trace<S, A> of(final List<? extends S> states, final List<? extends A> actions); int length(); S getState(final int i); A getAction(final int i); List<S> getStates(); List<A> getActions(); Trace<S, A> reverse(); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString();  }
@Test public void testReverse() { final Trace<?, ?> trace = Trace.of(of(s0, s1, s2), of(a0, a1)); final Trace<?, ?> reverse = trace.reverse(); Assert.assertEquals(trace.length(), reverse.length()); Assert.assertEquals(trace.getStates().size(), reverse.getStates().size()); Assert.assertEquals(trace.getActions().size(), reverse.getActions().size()); Assert.assertEquals(s2, reverse.getState(0)); Assert.assertEquals(s1, reverse.getState(1)); Assert.assertEquals(s0, reverse.getState(2)); Assert.assertEquals(a1, reverse.getAction(0)); Assert.assertEquals(a0, reverse.getAction(1)); Assert.assertEquals(trace, trace.reverse().reverse()); Assert.assertNotEquals(trace, trace.reverse()); }