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; 024import javax.annotation.CheckForNull; 025import org.checkerframework.checker.nullness.qual.Nullable; 026 027/** 028 * A table which forwards all its method calls to another table. Subclasses should override one or 029 * more methods to modify the behavior of the backing 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.0 034 */ 035@GwtCompatible 036public abstract class ForwardingTable< 037 R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object> 038 extends ForwardingObject implements Table<R, C, V> { 039 /** Constructor for use by subclasses. */ 040 protected ForwardingTable() {} 041 042 @Override 043 protected abstract Table<R, C, V> delegate(); 044 045 @Override 046 public Set<Cell<R, C, V>> cellSet() { 047 return delegate().cellSet(); 048 } 049 050 @Override 051 public void clear() { 052 delegate().clear(); 053 } 054 055 @Override 056 public Map<R, V> column(@ParametricNullness C columnKey) { 057 return delegate().column(columnKey); 058 } 059 060 @Override 061 public Set<C> columnKeySet() { 062 return delegate().columnKeySet(); 063 } 064 065 @Override 066 public Map<C, Map<R, V>> columnMap() { 067 return delegate().columnMap(); 068 } 069 070 @Override 071 public boolean contains(@CheckForNull Object rowKey, @CheckForNull Object columnKey) { 072 return delegate().contains(rowKey, columnKey); 073 } 074 075 @Override 076 public boolean containsColumn(@CheckForNull Object columnKey) { 077 return delegate().containsColumn(columnKey); 078 } 079 080 @Override 081 public boolean containsRow(@CheckForNull Object rowKey) { 082 return delegate().containsRow(rowKey); 083 } 084 085 @Override 086 public boolean containsValue(@CheckForNull Object value) { 087 return delegate().containsValue(value); 088 } 089 090 @Override 091 @CheckForNull 092 public V get(@CheckForNull Object rowKey, @CheckForNull Object columnKey) { 093 return delegate().get(rowKey, columnKey); 094 } 095 096 @Override 097 public boolean isEmpty() { 098 return delegate().isEmpty(); 099 } 100 101 @CanIgnoreReturnValue 102 @Override 103 @CheckForNull 104 public V put( 105 @ParametricNullness R rowKey, @ParametricNullness C columnKey, @ParametricNullness V value) { 106 return delegate().put(rowKey, columnKey, value); 107 } 108 109 @Override 110 public void putAll(Table<? extends R, ? extends C, ? extends V> table) { 111 delegate().putAll(table); 112 } 113 114 @CanIgnoreReturnValue 115 @Override 116 @CheckForNull 117 public V remove(@CheckForNull Object rowKey, @CheckForNull Object columnKey) { 118 return delegate().remove(rowKey, columnKey); 119 } 120 121 @Override 122 public Map<C, V> row(@ParametricNullness R rowKey) { 123 return delegate().row(rowKey); 124 } 125 126 @Override 127 public Set<R> rowKeySet() { 128 return delegate().rowKeySet(); 129 } 130 131 @Override 132 public Map<R, Map<C, V>> rowMap() { 133 return delegate().rowMap(); 134 } 135 136 @Override 137 public int size() { 138 return delegate().size(); 139 } 140 141 @Override 142 public Collection<V> values() { 143 return delegate().values(); 144 } 145 146 @Override 147 public boolean equals(@CheckForNull Object obj) { 148 return (obj == this) || delegate().equals(obj); 149 } 150 151 @Override 152 public int hashCode() { 153 return delegate().hashCode(); 154 } 155}