@Override public boolean hasNext() { canremove = false; if (nextObject != null) { return true; } while (iterator.hasNext()) { final Object obj = iterator.next(); final T f = filter.filter(obj); if (f != null) { nextObject = f; return true; } } return false; }
@Override public void remove() { if (!canremove) { throw new IllegalStateException( "remove() can only be called " + "on the FilterIterator immediately after a successful " + "call to next(). A call to remove() immediately after " + "a call to hasNext() or remove() will also fail."); } canremove = false; iterator.remove(); }
@Override public Iterator<T> iterator() { return new FilterIterator<T>(iterator.iterator(), filter); }