### Question:
FilteringStateChangeListenable implements StateChangeListenable<C> { @Override public void registerStateAddedOrRemovedListener(Consumer<? super C> consumer) { backingListenable.registerStateChangeListener((old, updated) -> { C oldPlannable = mapAndFilter.apply(old); C updatedPlannable = mapAndFilter.apply(updated); if (oldPlannable == null && updatedPlannable != null) { consumer.accept(updatedPlannable); } else if (oldPlannable != null && updatedPlannable == null) { consumer.accept(oldPlannable); } }); } FilteringStateChangeListenable(StateChangeListenable<T> backingListenable, Function<? super T, C> mapAndFilter); @Override T registerCustomIndex(T index); @Override void registerStateAddedOrRemovedListener(Consumer<? super C> consumer); @Override void registerStateChangeListener(CacheStateChangeListener<? super C> listener); @Override void registerStateAddedListener(CacheStateAddedListener<? super C> listener); @Override void registerStateRemovedListener(CacheStateRemovedListener<? super C> listener); @Override Stream<C> stream(); @Override UnmodifiableIterator<C> iterator(); @Override void registerAtomicStateChangeListener(AtomicStateChangeListener<? super C> listener); @Override void removeStateChangeListener(CacheStateChangeListener<? super C> listener);  }### Answer:
@Test void whenOnlyListeningForExtendedStates_thenAddOrRemovedOnlyReceivedExtendedStates() { (new FilteringStateChangeListenable<>(cache, this::asExtended)).registerStateAddedOrRemovedListener(s -> { result = true; resultUpdated = s; }); cache.add(state1); assertFalse(result); cache.add(extended1); assertTrue(result); assertEquals(extended1, resultUpdated); resetResult(); cache.update(state1, state1Updated); assertFalse(result); cache.update(extended1, extended1Updated); assertFalse(result); cache.delete(state1Updated.getId()); assertFalse(result); cache.delete(extended1Updated.getId()); assertTrue(result); assertEquals(extended1Updated, resultUpdated); }