1 /* 2 * Copyright (C) 2009 The Guava Authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.common.collect; 18 19 import com.google.common.annotations.GwtCompatible; 20 21 import java.util.Collection; 22 import java.util.Map; 23 import java.util.Set; 24 25 /** 26 * A table which forwards all its method calls to another table. Subclasses 27 * should override one or more methods to modify the behavior of the backing 28 * map as desired per the <a 29 * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>. 30 * 31 * @author Gregory Kick 32 * @since 7.0 33 */ 34 @GwtCompatible 35 public abstract class ForwardingTable<R, C, V> extends ForwardingObject 36 implements Table<R, C, V> { 37 /** Constructor for use by subclasses. */ ForwardingTable()38 protected ForwardingTable() {} 39 delegate()40 @Override protected abstract Table<R, C, V> delegate(); 41 42 @Override cellSet()43 public Set<Cell<R, C, V>> cellSet() { 44 return delegate().cellSet(); 45 } 46 47 @Override clear()48 public void clear() { 49 delegate().clear(); 50 } 51 52 @Override column(C columnKey)53 public Map<R, V> column(C columnKey) { 54 return delegate().column(columnKey); 55 } 56 57 @Override columnKeySet()58 public Set<C> columnKeySet() { 59 return delegate().columnKeySet(); 60 } 61 62 @Override columnMap()63 public Map<C, Map<R, V>> columnMap() { 64 return delegate().columnMap(); 65 } 66 67 @Override contains(Object rowKey, Object columnKey)68 public boolean contains(Object rowKey, Object columnKey) { 69 return delegate().contains(rowKey, columnKey); 70 } 71 72 @Override containsColumn(Object columnKey)73 public boolean containsColumn(Object columnKey) { 74 return delegate().containsColumn(columnKey); 75 } 76 77 @Override containsRow(Object rowKey)78 public boolean containsRow(Object rowKey) { 79 return delegate().containsRow(rowKey); 80 } 81 82 @Override containsValue(Object value)83 public boolean containsValue(Object value) { 84 return delegate().containsValue(value); 85 } 86 87 @Override get(Object rowKey, Object columnKey)88 public V get(Object rowKey, Object columnKey) { 89 return delegate().get(rowKey, columnKey); 90 } 91 92 @Override isEmpty()93 public boolean isEmpty() { 94 return delegate().isEmpty(); 95 } 96 97 @Override put(R rowKey, C columnKey, V value)98 public V put(R rowKey, C columnKey, V value) { 99 return delegate().put(rowKey, columnKey, value); 100 } 101 102 @Override putAll(Table<? extends R, ? extends C, ? extends V> table)103 public void putAll(Table<? extends R, ? extends C, ? extends V> table) { 104 delegate().putAll(table); 105 } 106 107 @Override remove(Object rowKey, Object columnKey)108 public V remove(Object rowKey, Object columnKey) { 109 return delegate().remove(rowKey, columnKey); 110 } 111 112 @Override row(R rowKey)113 public Map<C, V> row(R rowKey) { 114 return delegate().row(rowKey); 115 } 116 117 @Override rowKeySet()118 public Set<R> rowKeySet() { 119 return delegate().rowKeySet(); 120 } 121 122 @Override rowMap()123 public Map<R, Map<C, V>> rowMap() { 124 return delegate().rowMap(); 125 } 126 127 @Override size()128 public int size() { 129 return delegate().size(); 130 } 131 132 @Override values()133 public Collection<V> values() { 134 return delegate().values(); 135 } 136 equals(Object obj)137 @Override public boolean equals(Object obj) { 138 return (obj == this) || delegate().equals(obj); 139 } 140 hashCode()141 @Override public int hashCode() { 142 return delegate().hashCode(); 143 } 144 } 145