Coverage Summary for Class: ForwardingIterator (com.google.common.collect)

Class Class, % Method, % Line, %
ForwardingIterator 0% (0/1) 0% (0/4) 0% (0/4)


1 /* 2  * Copyright (C) 2007 The Guava Authors 3  * 4  * Licensed under the Apache License, Version 2.0 (the "License"); 5  * you may not use this file except in compliance with the License. 6  * You may obtain a copy of the License at 7  * 8  * http://www.apache.org/licenses/LICENSE-2.0 9  * 10  * Unless required by applicable law or agreed to in writing, software 11  * distributed under the License is distributed on an "AS IS" BASIS, 12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13  * See the License for the specific language governing permissions and 14  * limitations under the License. 15  */ 16  17 package com.google.common.collect; 18  19 import com.google.common.annotations.GwtCompatible; 20 import com.google.errorprone.annotations.CanIgnoreReturnValue; 21 import java.util.Iterator; 22  23 /** 24  * An iterator which forwards all its method calls to another iterator. Subclasses should override 25  * one or more methods to modify the behavior of the backing iterator as desired per the <a 26  * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>. 27  * 28  * <p><b>{@code default} method warning:</b> This class forwards calls to <i>only some</i> {@code 29  * default} methods. Specifically, it forwards calls only for methods that existed <a 30  * href="https://docs.oracle.com/javase/7/docs/api/java/util/Iterator.html">before {@code default} 31  * methods were introduced</a>. For newer methods, like {@code forEachRemaining}, it inherits their 32  * default implementations. When those implementations invoke methods, they invoke methods on the 33  * {@code ForwardingIterator}. 34  * 35  * @author Kevin Bourrillion 36  * @since 2.0 37  */ 38 @GwtCompatible 39 public abstract class ForwardingIterator<T> extends ForwardingObject implements Iterator<T> { 40  41  /** Constructor for use by subclasses. */ 42  protected ForwardingIterator() {} 43  44  @Override 45  protected abstract Iterator<T> delegate(); 46  47  @Override 48  public boolean hasNext() { 49  return delegate().hasNext(); 50  } 51  52  @CanIgnoreReturnValue 53  @Override 54  public T next() { 55  return delegate().next(); 56  } 57  58  @Override 59  public void remove() { 60  delegate().remove(); 61  } 62 }