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; 020 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 @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 @Override 108 public V remove(Object rowKey, Object columnKey) { 109 return delegate().remove(rowKey, columnKey); 110 } 111 112 @Override 113 public Map<C, V> row(R rowKey) { 114 return delegate().row(rowKey); 115 } 116 117 @Override 118 public Set<R> rowKeySet() { 119 return delegate().rowKeySet(); 120 } 121 122 @Override 123 public Map<R, Map<C, V>> rowMap() { 124 return delegate().rowMap(); 125 } 126 127 @Override 128 public int size() { 129 return delegate().size(); 130 } 131 132 @Override 133 public Collection<V> values() { 134 return delegate().values(); 135 } 136 137 @Override 138 public boolean equals(Object obj) { 139 return (obj == this) || delegate().equals(obj); 140 } 141 142 @Override 143 public int hashCode() { 144 return delegate().hashCode(); 145 } 146}