ForwardingTable.java revision 0888a09821a98ac0680fad765217302858e70fa4
1/*
2 * Copyright (C) 2009 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
17package com.google.common.collect;
18
19import com.google.common.annotations.GwtCompatible;
20
21import java.util.Collection;
22import java.util.Map;
23import java.util.Set;
24
25/**
26 * A table which forwards all its method calls to another table. Subclasses
27 * should override one or more methods to modify the behavior of the backing
28 * map as desired per the <a
29 * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>.
30 *
31 * @author Gregory Kick
32 * @since 7.0
33 */
34@GwtCompatible
35public abstract class ForwardingTable<R, C, V> extends ForwardingObject
36    implements Table<R, C, V> {
37  /** Constructor for use by subclasses. */
38  protected ForwardingTable() {}
39
40  @Override protected abstract Table<R, C, V> delegate();
41
42  @Override
43  public Set<Cell<R, C, V>> cellSet() {
44    return delegate().cellSet();
45  }
46
47  @Override
48  public void clear() {
49    delegate().clear();
50  }
51
52  @Override
53  public Map<R, V> column(C columnKey) {
54    return delegate().column(columnKey);
55  }
56
57  @Override
58  public Set<C> columnKeySet() {
59    return delegate().columnKeySet();
60  }
61
62  @Override
63  public Map<C, Map<R, V>> columnMap() {
64    return delegate().columnMap();
65  }
66
67  @Override
68  public boolean contains(Object rowKey, Object columnKey) {
69    return delegate().contains(rowKey, columnKey);
70  }
71
72  @Override
73  public boolean containsColumn(Object columnKey) {
74    return delegate().containsColumn(columnKey);
75  }
76
77  @Override
78  public boolean containsRow(Object rowKey) {
79    return delegate().containsRow(rowKey);
80  }
81
82  @Override
83  public boolean containsValue(Object value) {
84    return delegate().containsValue(value);
85  }
86
87  @Override
88  public V get(Object rowKey, Object columnKey) {
89    return delegate().get(rowKey, columnKey);
90  }
91
92  @Override
93  public boolean isEmpty() {
94    return delegate().isEmpty();
95  }
96
97  @Override
98  public V put(R rowKey, C columnKey, V value) {
99    return delegate().put(rowKey, columnKey, value);
100  }
101
102  @Override
103  public void putAll(Table<? extends R, ? extends C, ? extends V> table) {
104    delegate().putAll(table);
105  }
106
107  @Override
108  public V remove(Object rowKey, Object columnKey) {
109    return delegate().remove(rowKey, columnKey);
110  }
111
112  @Override
113  public Map<C, V> row(R rowKey) {
114    return delegate().row(rowKey);
115  }
116
117  @Override
118  public Set<R> rowKeySet() {
119    return delegate().rowKeySet();
120  }
121
122  @Override
123  public Map<R, Map<C, V>> rowMap() {
124    return delegate().rowMap();
125  }
126
127  @Override
128  public int size() {
129    return delegate().size();
130  }
131
132  @Override
133  public Collection<V> values() {
134    return delegate().values();
135  }
136
137  @Override public boolean equals(Object obj) {
138    return (obj == this) || delegate().equals(obj);
139  }
140
141  @Override public int hashCode() {
142    return delegate().hashCode();
143  }
144}
145