class FilteringStateChangeListenable implements StateChangeListenable<C> {

    @Override
    public UnmodifiableIterator<C> iterator() {
        return new UnmodifiableIterator<C>() {
            private final UnmodifiableIterator<T> backingIterator = backingListenable.iterator();

            private @CheckForNull C nextValue = backingNext();

            @Override
            public boolean hasNext() {
                return nextValue != null;
            }

            @Override
            public C next() {
                C c = nextValue;
                if (c == null) {
                    throw new NoSuchElementException();
                }
                nextValue = backingNext();
                return c;
            }

            private C backingNext() {
                C c = null;
                while (c == null && backingIterator.hasNext()) {
                    c = mapAndFilter.apply(backingIterator.next());
                }
                return c;
            }
        };
    }

    public  FilteringStateChangeListenable(StateChangeListenable<T> backingListenable, Function<? super T, C> mapAndFilter);

}