001    /*
002     * Copyright (C) 2009 Google Inc.
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
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      public Set<Cell<R, C, V>> cellSet() {
045        return delegate().cellSet();
046      }
047    
048      public void clear() {
049        delegate().clear();
050      }
051    
052      public Map<R, V> column(C columnKey) {
053        return delegate().column(columnKey);
054      }
055    
056      public Set<C> columnKeySet() {
057        return delegate().columnKeySet();
058      }
059    
060      public Map<C, Map<R, V>> columnMap() {
061        return delegate().columnMap();
062      }
063    
064      public boolean contains(Object rowKey, Object columnKey) {
065        return delegate().contains(rowKey, columnKey);
066      }
067    
068      public boolean containsColumn(Object columnKey) {
069        return delegate().containsColumn(columnKey);
070      }
071    
072      public boolean containsRow(Object rowKey) {
073        return delegate().containsRow(rowKey);
074      }
075    
076      public boolean containsValue(Object value) {
077        return delegate().containsValue(value);
078      }
079    
080      public V get(Object rowKey, Object columnKey) {
081        return delegate().get(rowKey, columnKey);
082      }
083    
084      public boolean isEmpty() {
085        return delegate().isEmpty();
086      }
087    
088      public V put(R rowKey, C columnKey, V value) {
089        return delegate().put(rowKey, columnKey, value);
090      }
091    
092      public void putAll(Table<? extends R, ? extends C, ? extends V> table) {
093        delegate().putAll(table);
094      }
095    
096      public V remove(Object rowKey, Object columnKey) {
097        return delegate().remove(rowKey, columnKey);
098      }
099    
100      public Map<C, V> row(R rowKey) {
101        return delegate().row(rowKey);
102      }
103    
104      public Set<R> rowKeySet() {
105        return delegate().rowKeySet();
106      }
107    
108      public Map<R, Map<C, V>> rowMap() {
109        return delegate().rowMap();
110      }
111    
112      public int size() {
113        return delegate().size();
114      }
115    
116      public Collection<V> values() {
117        return delegate().values();
118      }
119    
120      @Override public boolean equals(Object obj) {
121        return (obj == this) || delegate().equals(obj);
122      }
123    
124      @Override public int hashCode() {
125        return delegate().hashCode();
126      }
127    }