CallbackRegistry implements Cloneable { public synchronized boolean isEmpty() { if (mCallbacks.isEmpty()) { return true; } else if (mNotificationLevel == 0) { return false; } else { int numListeners = mCallbacks.size(); for (int i = 0; i < numListeners; i++) { if (!isRemoved(i)) { return false; } } return true; } } CallbackRegistry(NotifierCallback<C, T, A> notifier); synchronized void notifyCallbacks(T sender, int arg, A arg2); synchronized void add(C callback); synchronized void remove(C callback); synchronized ArrayList<C> copyCallbacks(); synchronized void copyCallbacks(List<C> callbacks); synchronized boolean isEmpty(); synchronized void clear(); @SuppressWarnings("unchecked") synchronized CallbackRegistry<C, T, A> clone();  }
@Test public void testIsEmpty() throws Exception { CallbackRegistry.NotifierCallback<Integer, CallbackRegistryTest, Integer> notifier = new CallbackRegistry.NotifierCallback<Integer, CallbackRegistryTest, Integer>() { @Override public void onNotifyCallback(Integer callback, CallbackRegistryTest sender, int arg, Integer arg2) { } }; registry = new CallbackRegistry<Integer, CallbackRegistryTest, Integer>(notifier); Integer callback = 0; assertTrue(registry.isEmpty()); registry.add(callback); assertFalse(registry.isEmpty()); }