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