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
017package com.google.common.collect;
018
019import com.google.common.annotations.GwtCompatible;
020import com.google.errorprone.annotations.CanIgnoreReturnValue;
021import java.util.Collection;
022import java.util.Map;
023import java.util.Set;
024
025/**
026 * A table which forwards all its method calls to another table. Subclasses should override one or
027 * more methods to modify the behavior of the backing map as desired per the <a
028 * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>.
029 *
030 * @author Gregory Kick
031 * @since 7.0
032 */
033@GwtCompatible
034public abstract class ForwardingTable<R, C, V> extends ForwardingObject implements Table<R, C, V> {
035  /** Constructor for use by subclasses. */
036  protected ForwardingTable() {}
037
038  @Override
039  protected abstract Table<R, C, V> delegate();
040
041  @Override
042  public Set<Cell<R, C, V>> cellSet() {
043    return delegate().cellSet();
044  }
045
046  @Override
047  public void clear() {
048    delegate().clear();
049  }
050
051  @Override
052  public Map<R, V> column(C columnKey) {
053    return delegate().column(columnKey);
054  }
055
056  @Override
057  public Set<C> columnKeySet() {
058    return delegate().columnKeySet();
059  }
060
061  @Override
062  public Map<C, Map<R, V>> columnMap() {
063    return delegate().columnMap();
064  }
065
066  @Override
067  public boolean contains(Object rowKey, Object columnKey) {
068    return delegate().contains(rowKey, columnKey);
069  }
070
071  @Override
072  public boolean containsColumn(Object columnKey) {
073    return delegate().containsColumn(columnKey);
074  }
075
076  @Override
077  public boolean containsRow(Object rowKey) {
078    return delegate().containsRow(rowKey);
079  }
080
081  @Override
082  public boolean containsValue(Object value) {
083    return delegate().containsValue(value);
084  }
085
086  @Override
087  public V get(Object rowKey, Object columnKey) {
088    return delegate().get(rowKey, columnKey);
089  }
090
091  @Override
092  public boolean isEmpty() {
093    return delegate().isEmpty();
094  }
095
096  @CanIgnoreReturnValue
097  @Override
098  public V put(R rowKey, C columnKey, V value) {
099    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  @CanIgnoreReturnValue
108  @Override
109  public V remove(Object rowKey, Object columnKey) {
110    return delegate().remove(rowKey, columnKey);
111  }
112
113  @Override
114  public Map<C, V> row(R rowKey) {
115    return delegate().row(rowKey);
116  }
117
118  @Override
119  public Set<R> rowKeySet() {
120    return delegate().rowKeySet();
121  }
122
123  @Override
124  public Map<R, Map<C, V>> rowMap() {
125    return delegate().rowMap();
126  }
127
128  @Override
129  public int size() {
130    return delegate().size();
131  }
132
133  @Override
134  public Collection<V> values() {
135    return delegate().values();
136  }
137
138  @Override
139  public boolean equals(Object obj) {
140    return (obj == this) || delegate().equals(obj);
141  }
142
143  @Override
144  public int hashCode() {
145    return delegate().hashCode();
146  }
147}