### Question:
NullarySequence implements NullaryProcedure { public final NullarySequence then(NullaryProcedure p) { if (p != null) { list.add(p); } return this; } NullarySequence();  NullarySequence(NullaryProcedure... procedures);  NullarySequence(Iterable<NullaryProcedure> procedures); final NullarySequence then(NullaryProcedure p); final void run(); @Override final boolean equals(Object obj); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void testThen() throws Exception { List<RunCounter> list = new ArrayList<RunCounter>(); NullarySequence seq = new NullarySequence(); seq.run(); for (int i=0;i<10;i++) { RunCounter counter = new RunCounter(); seq.then(counter); list.add(counter); seq.run(); for (int j=0;j<list.size();j++) { assertEquals(list.size()-j,(((RunCounter)(list.get(j))).count)); } } }