1090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson/*
2090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * Copyright (C) 2007 Google Inc.
3090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson *
4090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * Licensed under the Apache License, Version 2.0 (the "License");
5090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * you may not use this file except in compliance with the License.
6090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * You may obtain a copy of the License at
7090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson *
8090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * http://www.apache.org/licenses/LICENSE-2.0
9090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson *
10090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * Unless required by applicable law or agreed to in writing, software
11090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * distributed under the License is distributed on an "AS IS" BASIS,
12090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * See the License for the specific language governing permissions and
14090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * limitations under the License.
15090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson */
16090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
17090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonpackage com.google.common.collect;
18090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
19090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonimport com.google.common.annotations.GwtCompatible;
20090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
21090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonimport java.util.Collection;
22090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonimport java.util.Iterator;
23090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
24090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson/**
25090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * A collection which forwards all its method calls to another collection.
26090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * Subclasses should override one or more methods to modify the behavior of
27090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * the backing collection as desired per the <a
28090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>.
29090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson *
30090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * @see ForwardingObject
31090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * @author Kevin Bourrillion
32bfe2dd089341dcb4c1fb65a5b6b077ad0ebbf6dcDan Egnor * @since 2010.01.04 <b>stable</b> (imported from Google Collections Library)
33090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson */
34090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson@GwtCompatible
35090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonpublic abstract class ForwardingCollection<E> extends ForwardingObject
36090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    implements Collection<E> {
37090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
38090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  @Override protected abstract Collection<E> delegate();
39090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
40090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public Iterator<E> iterator() {
41090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().iterator();
42090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
43090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
44090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public int size() {
45090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().size();
46090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
47090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
48090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public boolean removeAll(Collection<?> collection) {
49090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().removeAll(collection);
50090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
51090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
52090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public boolean isEmpty() {
53090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().isEmpty();
54090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
55090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
56090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public boolean contains(Object object) {
57090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().contains(object);
58090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
59090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
60090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public Object[] toArray() {
61090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().toArray();
62090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
63090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
64090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public <T> T[] toArray(T[] array) {
65090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().toArray(array);
66090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
67090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
68090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public boolean add(E element) {
69090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().add(element);
70090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
71090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
72090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public boolean remove(Object object) {
73090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().remove(object);
74090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
75090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
76090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public boolean containsAll(Collection<?> collection) {
77090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().containsAll(collection);
78090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
79090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
80090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public boolean addAll(Collection<? extends E> collection) {
81090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().addAll(collection);
82090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
83090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
84090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public boolean retainAll(Collection<?> collection) {
85090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().retainAll(collection);
86090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
87090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
88090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public void clear() {
89090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    delegate().clear();
90090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
91090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson}
92