001 /*
002 * Copyright (C) 2009 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.Beta;
020 import com.google.common.annotations.GwtCompatible;
021
022 import java.util.Collection;
023 import java.util.Map;
024 import java.util.Set;
025
026 /**
027 * A table which forwards all its method calls to another table. Subclasses
028 * should override one or more methods to modify the behavior of the backing
029 * map as desired per the <a
030 * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>.
031 *
032 * @author Gregory Kick
033 * @since 7.0
034 */
035 @Beta
036 @GwtCompatible
037 public abstract class ForwardingTable<R, C, V> extends ForwardingObject
038 implements Table<R, C, V> {
039 /** Constructor for use by subclasses. */
040 protected ForwardingTable() {}
041
042 @Override protected abstract Table<R, C, V> delegate();
043
044 @Override
045 public Set<Cell<R, C, V>> cellSet() {
046 return delegate().cellSet();
047 }
048
049 @Override
050 public void clear() {
051 delegate().clear();
052 }
053
054 @Override
055 public Map<R, V> column(C columnKey) {
056 return delegate().column(columnKey);
057 }
058
059 @Override
060 public Set<C> columnKeySet() {
061 return delegate().columnKeySet();
062 }
063
064 @Override
065 public Map<C, Map<R, V>> columnMap() {
066 return delegate().columnMap();
067 }
068
069 @Override
070 public boolean contains(Object rowKey, Object columnKey) {
071 return delegate().contains(rowKey, columnKey);
072 }
073
074 @Override
075 public boolean containsColumn(Object columnKey) {
076 return delegate().containsColumn(columnKey);
077 }
078
079 @Override
080 public boolean containsRow(Object rowKey) {
081 return delegate().containsRow(rowKey);
082 }
083
084 @Override
085 public boolean containsValue(Object value) {
086 return delegate().containsValue(value);
087 }
088
089 @Override
090 public V get(Object rowKey, Object columnKey) {
091 return delegate().get(rowKey, columnKey);
092 }
093
094 @Override
095 public boolean isEmpty() {
096 return delegate().isEmpty();
097 }
098
099 @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 }