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
027 * should override one or more methods to modify the behavior of the backing
028 * map as desired per the <a
029 * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>.
030 *
031 * @author Gregory Kick
032 * @since 7.0
033 */
034@GwtCompatible
035public abstract class ForwardingTable<R, C, V> extends ForwardingObject implements Table<R, C, V> {
036  /** Constructor for use by subclasses. */
037  protected ForwardingTable() {}
038
039  @Override
040  protected abstract Table<R, C, V> delegate();
041
042  @Override
043  public Set<Cell<R, C, V>> cellSet() {
044    return delegate().cellSet();
045  }
046
047  @Override
048  public void clear() {
049    delegate().clear();
050  }
051
052  @Override
053  public Map<R, V> column(C columnKey) {
054    return delegate().column(columnKey);
055  }
056
057  @Override
058  public Set<C> columnKeySet() {
059    return delegate().columnKeySet();
060  }
061
062  @Override
063  public Map<C, Map<R, V>> columnMap() {
064    return delegate().columnMap();
065  }
066
067  @Override
068  public boolean contains(Object rowKey, Object columnKey) {
069    return delegate().contains(rowKey, columnKey);
070  }
071
072  @Override
073  public boolean containsColumn(Object columnKey) {
074    return delegate().containsColumn(columnKey);
075  }
076
077  @Override
078  public boolean containsRow(Object rowKey) {
079    return delegate().containsRow(rowKey);
080  }
081
082  @Override
083  public boolean containsValue(Object value) {
084    return delegate().containsValue(value);
085  }
086
087  @Override
088  public V get(Object rowKey, Object columnKey) {
089    return delegate().get(rowKey, columnKey);
090  }
091
092  @Override
093  public boolean isEmpty() {
094    return delegate().isEmpty();
095  }
096
097  @CanIgnoreReturnValue
098  @Override
099  public V put(R rowKey, C columnKey, V value) {
100    return delegate().put(rowKey, columnKey, value);
101  }
102
103  @Override
104  public void putAll(Table<? extends R, ? extends C, ? extends V> table) {
105    delegate().putAll(table);
106  }
107
108  @CanIgnoreReturnValue
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
140  public boolean equals(Object obj) {
141    return (obj == this) || delegate().equals(obj);
142  }
143
144  @Override
145  public int hashCode() {
146    return delegate().hashCode();
147  }
148}