public FilterIterator(Iterator<T> delegate, Filter<T> filter) {
        if (delegate == null) {
            throw new IllegalArgumentException(
                    "The given iteration delegate must not be null.");
        }
        if (filter == null) {
            throw new IllegalArgumentException(
                    "The given filter must not be null.");
        }

        this.delegate = delegate;
        this.filter = filter;

        // Immediately try to look for the first valid element. In
        // doing so, we know that this iterator has reached the end
        // of the collection if "next" is null.
        advance();
    }