001 /*
002 * Copyright (C) 2007 The Guava Authors
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 package com.google.common.collect;
018
019 import com.google.common.annotations.GwtCompatible;
020
021 import java.util.ListIterator;
022
023 /**
024 * A list iterator which forwards all its method calls to another list
025 * iterator. Subclasses should override one or more methods to modify the
026 * behavior of the backing iterator as desired per the <a
027 * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>.
028 *
029 * @author Mike Bostock
030 * @since 2.0 (imported from Google Collections Library)
031 */
032 @GwtCompatible
033 public abstract class ForwardingListIterator<E> extends ForwardingIterator<E>
034 implements ListIterator<E> {
035
036 /** Constructor for use by subclasses. */
037 protected ForwardingListIterator() {}
038
039
040 @Override
041 protected abstract ListIterator<E> delegate();
042
043 public void add(E element) {
044 delegate().add(element);
045 }
046
047 public boolean hasPrevious() {
048 return delegate().hasPrevious();
049 }
050
051 public int nextIndex() {
052 return delegate().nextIndex();
053 }
054
055 public E previous() {
056 return delegate().previous();
057 }
058
059 public int previousIndex() {
060 return delegate().previousIndex();
061 }
062
063 public void set(E element) {
064 delegate().set(element);
065 }
066 }