• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 Google Inc.
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 
21 import java.util.Collection;
22 import java.util.Iterator;
23 
24 /**
25  * A collection which forwards all its method calls to another collection.
26  * Subclasses should override one or more methods to modify the behavior of
27  * the backing collection as desired per the <a
28  * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>.
29  *
30  * @see ForwardingObject
31  * @author Kevin Bourrillion
32  * @since 2010.01.04 <b>stable</b> (imported from Google Collections Library)
33  */
34 @GwtCompatible
35 public abstract class ForwardingCollection<E> extends ForwardingObject
36     implements Collection<E> {
37 
delegate()38   @Override protected abstract Collection<E> delegate();
39 
iterator()40   public Iterator<E> iterator() {
41     return delegate().iterator();
42   }
43 
size()44   public int size() {
45     return delegate().size();
46   }
47 
removeAll(Collection<?> collection)48   public boolean removeAll(Collection<?> collection) {
49     return delegate().removeAll(collection);
50   }
51 
isEmpty()52   public boolean isEmpty() {
53     return delegate().isEmpty();
54   }
55 
contains(Object object)56   public boolean contains(Object object) {
57     return delegate().contains(object);
58   }
59 
toArray()60   public Object[] toArray() {
61     return delegate().toArray();
62   }
63 
toArray(T[] array)64   public <T> T[] toArray(T[] array) {
65     return delegate().toArray(array);
66   }
67 
add(E element)68   public boolean add(E element) {
69     return delegate().add(element);
70   }
71 
remove(Object object)72   public boolean remove(Object object) {
73     return delegate().remove(object);
74   }
75 
containsAll(Collection<?> collection)76   public boolean containsAll(Collection<?> collection) {
77     return delegate().containsAll(collection);
78   }
79 
addAll(Collection<? extends E> collection)80   public boolean addAll(Collection<? extends E> collection) {
81     return delegate().addAll(collection);
82   }
83 
retainAll(Collection<?> collection)84   public boolean retainAll(Collection<?> collection) {
85     return delegate().retainAll(collection);
86   }
87 
clear()88   public void clear() {
89     delegate().clear();
90   }
91 }
92