Esempio n. 1
0
  @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;
  }
Esempio n. 2
0
 @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();
 }
Esempio n. 3
0
 @Override
 public Iterator<T> iterator() {
   return new FilterIterator<T>(iterator.iterator(), filter);
 }