private static Callback<Listener> terminatedCallback(final State from) { return new Callback<Listener>("terminated({from = " + from + "})") { @Override void call(Listener listener) { listener.terminated(from); } }; }
private static Callback<Listener> stoppingCallback(final State from) { return new Callback<Listener>("stopping({from = " + from + "})") { @Override void call(Listener listener) { listener.stopping(from); } }; }
@GuardedBy("monitor") private void failed(final State from, final Throwable cause) { // can't memoize this one due to the exception new Callback<Listener>("failed({from = " + from + ", cause = " + cause + "})") { @Override void call(Listener listener) { listener.failed(from, cause); } }.enqueueOn(listeners); }
@GuardedBy("monitor") void fireFailedListeners(final Service service) { new Callback<Listener>("failed({service=" + service + "})") { @Override void call(Listener listener) { listener.failure(service); } }.enqueueOn(listeners); }
private Callback<Object> incrementingCallback(final AtomicInteger counter, final int expected) { return new Callback<Object>("incrementing") { @Override void call(Object listener) { assertEquals(expected, counter.incrementAndGet()); } }; }
private Callback<Object> countDownCallback(final CountDownLatch latch) { return new Callback<Object>("countDown") { @Override void call(Object listener) { latch.countDown(); } }; }
@GuardedBy("monitor") private void failed( final State from, final Throwable cause) { // can't memoize this one due to the exception new Callback<Listener>("failed({from = " + from + ", cause = " + cause + "})") { @Override void call(Listener listener) { listener.failed(from, cause); } }.enqueueOn(listeners); }